Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Firstly solution in Clear category for The Hamming Distance by Haradd
def checkio(n, m):
d,i,p=0,0,0
if n>m:
p=n
n=m
m=p
n=str(bin(n))[::-1]
m=str(bin(m))[::-1]
while n[i]!='b':
if n[i]!=m[i]:
d+=1
i+=1
while m[i]!='b':
if m[i]=='1':
d+=1
i+=1
return d
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. 24, 2016