xor_1.py 205 B

1234567
  1. def hamming(a, b, bitdepth):
  2. distance = 0
  3. for i in range(bitdepth - 1, -1, -1):
  4. bit_a = (a >> i) & 1
  5. bit_b = (b >> i) & 1
  6. distance += not(bit_a == bit_b)
  7. return distance