Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def max_ham_overlap(a,b,max_dist):
- """ returns the length of the
- def hamming_dist(w1,w2):
- l1 = len(w1)
- l2 = len(w2)
- score = abs(len(w1) - len(w2))
- for c1,c2 in zip(w1,w2):
- if c1 != c2:
- score += 1
- return score
- def max_ham_overlap(a,b,max_dist):
- distances = []
- c = min(len(a),(len(b))
- for i in range(1,c+1):
- if hamming_dist(a[-i:],b[0:i]) <= max_dist:
- distances.append(i)
- return max(distances)
- print max_ham_overlap("pollock","pollers",2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement