Fix bug in hamming distance: Difference in length between two strings must be

multiplied by 2.
This commit is contained in:
Albert Cervera i Areny 2008-09-14 23:57:35 +02:00
parent 9cc4af299d
commit 7cff77ef94
1 changed files with 3 additions and 1 deletions

View File

@ -49,7 +49,9 @@ class Hamming:
value += 1
continue
value += 2
value += abs( len(text1) - len(text2) )
# Note that we need to multiply by 2 because 'errors' weight 2
# and 'semi-errors' weight 1
value += abs( len(text1) - len(text2) ) * 2
return value
if __name__ == '__main__':