This problem asks:

Given: Two DNA strings s and t of equal length (not exceeding 1 kbp).

Return: The Hamming distance dH(s,t).

Restate the problem

I’m going to get two DNA strings of equal length, and I need to return a count of the places where those two strings are different.

Solution steps

This turned out to be as simple as it first looked, which is not usually so. I wrote the code in one pass and got the correct answer on the first attempt.

Python concepts

Looking through the solutions from others online, I see some clever Pythonic tricks to do this more succinctly than I did it, including many one-liners. I don’t see any solutions more plain and simple than mine.

Bioinformatics concepts

The Wikipedia entry for Hamming distance is interesting and includes Python code for calculating the Hamming distance for two strings. The example they give isn’t very different from the code I wrote.

Richard Hamming led a fascinating life.

Here is a in-depth roundtable discussion about his impact on the history of mathmatics.

Richard_Hamming.jpg

By unknown - Original publication: unknownImmediate source: http://cm.bell-labs.com/cm/cs/alumni/hamming/, Fair use, https://en.wikipedia.org/w/index.php?curid=40177109