implemented hamming distance