def hamming(str1, str2):
    """Algorithm based on an old project of mine, ported from yavascript:
    christabor.github.io/etude/09-02-2014/.

    A superior algorithm exists at
    wikipedia.org/wiki/Hamming_distance#Algorithm_example,
    but copying it would defeat the purpose."""
    dist = 0
    last_longer = len(str1) < len(str2)
    first, last = (str1, str2,) if last_longer else (str2, str1,)
    for k, letter in enumerate(str1):
        try:
            if str1[k] != str2[k]:
                dist += 1
        except __HOLE__:
            continue
    # Add remainder between offset of each (e.g. "cat", "cats" = range(2, 3))
    for k in range(len(first), len(last)):
        dist += 1
    print('Hamming dist for `{}` and `{}` = {}'.format(str1, str2, dist))
    return dist
dataset/ETHPy150Open christabor/MoAL/MOAL/algorithms/coding_theory/hamming_distance.py/hamming