computing the error for sequences with Hamming distance