Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sift3 in Python
def sift3(s1,s2, maxOffset):
s1L = len(s1)
s2L = len(s2)
if not s1:
return (not s2 and 0 or s2L)
if not s2:
return s1L
c1 = 0
c2 = 0
lcs = 0
while c1<s1L and c2<s2L:
if s1[c1] == s2[c2]:
lcs += 1
for i in range(1,maxOffset):
if c1+i < s1L and s1[c1+i] == s2[c2]:
c1 += i
if c2+i < s2L and s1[c1] == s2[c2+i]:
c2 += i
c1 += 1
c2 += 1
return ((s1L+s2L)/2-lcs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.