# Hamming distance between two DNA strings

By definition from Wikipedia, the Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. In other words, it is the number of substitutions required to transform one string into another. Given two strings of equal length, compute the Hamming distance.

So to find the how many differences there are between two strings, say we have two DNA strings A and B:

A = TGACCCGTTATGCTCGAGTTCGGTCAGAGCGTCATTGCGAGTAGTCGTTTGCTTTCTCAAACTCC
B = GAGCGATTAAGCGTGACAGCCCCAGGGAACCCACAAAACGTGATCGCAGTCCATCCGATCATACA


Throw them to two arrays A and B. Therefore, If

(= count 0)
(cond
[(symbol=? A B) /do nothing just move on to the next pair of string]
[else (add1 count)] ;; counter:= counter + 1;


output would be the counter.

Is this the right logic flow to go with this problem? Any suggestion to write this on python or Scheme?

• I think for the programming side of things, this question should be asked (at least in part) in stackoverflow.com – Bez Oct 27 '14 at 22:55
• This question does fit into bioinformatics, which is on-topic here. That said, it really has nothing to do with DNA and you might get a better response at stackoverlow. – canadianer Oct 28 '14 at 3:21
• By the way, this sounds a lot like a homework question and there is a tag for that here. – skymningen Oct 30 '14 at 7:30

def hamming_distance(s1, s2):