Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for The Hamming Distance by Vojtas
def checkio(n, m):
if m>n:
temp=n
n=m
m=temp
n=str(bin(n))
m=str(bin(m))
n=n[2:]
m=m[2:]
n=n[::-1]
m=m[::-1]
m=m+"0"*(len(n)-len(m))
suma=0
for i in range(len(m)):
if n[i]!=m[i]:
suma+=1
return suma
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. 17, 2018