In [16]:
def get_Hamming_weight(binary_number):
count = 0
for no in map(int, str(binary_number)):
if no:
count += 1
return count
print('Hamming weight of ' + str(1001) + ' is: ' + str(get_Hamming_weight(1001)))
def get_Hamming_distance(binary_a, binary_b):
count = 0
i = 0
for i in range(len(str(binary_a))):
if str(binary_a)[i] != str(binary_b)[i]:
count += 1
return count
print('Hamming distance of ' + str(1001) + ' and ' + str(1110) + ' is: ' + str(get_Hamming_distance(1001, 1110)))
In [ ]:
'''
Sure is Hw(u) ? (bytes of 1 of u) - seems like it ...
or is it Hd(v, u) - v being the closest word in C for u (with how many bytes does u modify v)
detection threshold for an error u
Hw(u) < d(C)-1
correction threshold for an error u
Hw(u) < \floor{ \frac{d(C)-1}{2} }
'''