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 KrzysztofP
def checkio(n, m):
n2='{0:b}'.format(n)
m2='{0:b}'.format(m)
if len(n2)len(m2):
m2=m2.zfill(len(n2))
counter=0
for i in range(len(m2)):
if n2[i]!=m2[i]:
counter+=1
return counter
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"
Oct. 31, 2016