Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. def max_ham_overlap(a,b,max_dist):
  2. """ returns the length of the
  3. def hamming_dist(w1,w2):
  4. l1 = len(w1)
  5. l2 = len(w2)
  6. score = abs(len(w1) - len(w2))
  7. for c1,c2 in zip(w1,w2):
  8. if c1 != c2:
  9. score += 1
  10. return score
  11.  
  12. def max_ham_overlap(a,b,max_dist):
  13. distances = []
  14. c = min(len(a),(len(b))
  15. for i in range(1,c+1):
  16. if hamming_dist(a[-i:],b[0:i]) <= max_dist:
  17. distances.append(i)
  18. return max(distances)
  19.  
  20. print max_ham_overlap("pollock","pollers",2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement