Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,28 @@
func lComSubStr(w1, w2) {
var (len, end) = (0, 0)
var mat = Array.Empty(w1.Length() + 1, () => Array.Empty(w2.Length() + 1, 0))
var (i, j) = (0, 0)
for sLett in w1 {
for tLett in w2 {
if tLett == sLett {
let curLen = mat[i][j] + 1
mat[i + 1][j + 1] = curLen
if curLen > len {
len = curLen
end = i
}
}
j += 1
}
j = 0
i += 1
}
String(values: w1).Substring((end + 1) - len, len)
}
func comSubStr(w1, w2) {
return String(lComSubStr(w1.Iterate().ToArray(), w2.Iterate().ToArray()))
}
comSubStr("thisisatest", "testing123testing") // "test"