Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -0,0 +1,17 @@
|
|||
program longest_common_substring;
|
||||
print(lcs("thisisatest", "testing123testing"));
|
||||
|
||||
proc lcs(s1, s2);
|
||||
if #s1 < #s2 then [s1, s2] := [s2, s1]; end if;
|
||||
|
||||
loop for l in [#s2, #s2-1..1] do
|
||||
loop for s in [1..#s2-l+1] do
|
||||
if (substr := s2(s..s+l)) in s1 then
|
||||
return substr;
|
||||
end if;
|
||||
end loop;
|
||||
end loop;
|
||||
|
||||
return "";
|
||||
end proc;
|
||||
end program;
|
||||
Loading…
Add table
Add a link
Reference in a new issue