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 Poetakodu
def checkio(n, m):
print(bin(n)[2:])
print(bin(m)[2:])
newn = "0"*(20-len(bin(n)[2:])) + bin(n)[2:]
newm = "0"*(20-len(bin(m)[2:])) + bin(m)[2:]
print(newn)
print(newm)
int = 0
wynik = 0
for int in range(20):
if newn[int] != newm[int]:
wynik += 1
return wynik
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. 4, 2016