Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
The Hamming Distance solution in Clear category for The Hamming Distance by mz97
def checkio(n, m):
hd=0
arr_n=[]
arr_m=[]
sn=""
sm=""
while n>0:
if n%2==1:
arr_n.append('1')
else:
arr_n.append('0')
n=int(n/2)
while m>0:
if m%2==1:
arr_m.append('1')
else:
arr_m.append('0')
m=int(m/2)
while len(arr_n)>len(arr_m):
arr_m.append('0')
while len(arr_m)>len(arr_n):
arr_n.append('0')
for i in range(len(arr_n)):
if arr_n[i] != arr_m[i]:
hd=hd+1
return hd
Oct. 14, 2016