MCPcopy
hub / github.com/jwasham/practice-python / hamming_distance

Function hamming_distance

bit_manipulation/bits.py:1–8  ·  view source on GitHub ↗
(x, y)

Source from the content-addressed store, hash-verified

1def hamming_distance(x, y):
2 difference = x ^ y
3 count = 0
4 while difference:
5 # this removes ones from right to left (least to most significant)
6 difference &= difference - 1
7 count += 1
8 return count
9
10
11# Wegner method

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected