photo_hash_1.py 311 B

12345678
  1. def hash_distance(left_hash, right_hash):
  2. """Compute the hamming distance between two hashes"""
  3. if len(left_hash) != len(right_hash):
  4. raise ValueError('Hamming distance requires two strings of equal length')
  5. return sum(map(lambda x: 0 if x[0] == x[1] else 1, zip(left_hash, right_hash)))