RosettaCodeData/Task/Longest-common-substring/AutoHotkey/longest-common-substring-1.ahk
2023-07-01 13:44:08 -04:00

8 lines
205 B
AutoHotkey

LCS(a, b){
x := i := 1
while StrLen(x)
Loop % StrLen(a)
IfInString, b, % x := SubStr(a, i:=StrLen(x)=1 ? i+1 : i, n:=StrLen(a)+1-A_Index)
res := StrLen(res) > StrLen(x) ? res : x
return res
}