Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Hamming Distance by Andreas_Strus
def checkio(n, m):
m = bin(m).replace("b", "")
n = bin(n).replace("b", "")
while len(n) > len(m):
m = "0" + m
while len(m) > len(n):
n = "0" + n
return sum(w != r for w, r, in zip(n, m))
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio(117, 17) == 3, "First example"
assert checkio(1, 2) == 2, "Second example"
assert checkio(16, 15) == 5, "Third example"
Nov. 9, 2016