def hamming_distance(s1, s2): assert len(s1) == len(s2) return sum([ch1 != ch2 for ch1, ch2 in zip(s1, s2)]) def test_hamming_distance(): s1,s2="0102304", "9375304" res = hamming_distance(s1, s2) print(res) print((s1,list(zip(s1,s2))))
def hamming_distance(s1, s2): assert len(s1) == len(s2) return sum([ch1 != ch2 for ch1, ch2 in zip(s1, s2)]) def test_hamming_distance(): s1,s2="0102304", "9375304" res = hamming_distance(s1, s2) print(res) print((s1,list(zip(s1,s2))))
Leave a Reply