function lcs(string a, b) integer la = length(a), lb = length(b), longest = 0 string best = "" for i,ch in a do for j=1 to lb do if ch=b[j] then integer l=1 while i+l<=la and j+l<=lb and a[i+l]=b[j+l] do l += 1 end while if l>longest then longest = l best = a[i..i+l-1] end if end if end for end for return best end function ?lcs("thisisatest","testing123testing") ?lcs("testing123testing","thisisatest")