#include <stdio.h>
unsigned hamdis(unsigned x, unsigned y)
{
//considered as binary values, that is, as sequences of bits
unsigned dist = 0, val = x ^ y;
while(val){
++dist;
val &= val-1;
}
return dist;
}
int main()
{
//01,10 hamming distance
printf("DIST:%d",hamdis(1,2));
getchar();
}
def hamming_distance(s1, s2):
#Return hamming distance betweent equal-length sequences
if len(s1) != len(s2):
raise ValueError("undefined for sequences of unequal length")
return sum(ch1 != ch2 for ch1, ch2 in zip(s1,s2))
print(hamming_distance("sfs","sft"))
#include unsigned hamdis(unsigned x, unsigned y){ //considered as binary values, that is, as sequences of bits unsigned dist = 0, val = x ^ y; while(val){ ++dist; val &= val-1; } return di