RosettaCodeData/Task/Longest-common-substring/AutoHotkey/longest-common-substring-1.ahk

9 lines
205 B
AutoHotkey
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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
}