Skip to content

Instantly share code, notes, and snippets.

@md2perpe
Created February 7, 2022 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save md2perpe/43bc2953546ea77451c441f59415289b to your computer and use it in GitHub Desktop.
Save md2perpe/43bc2953546ea77451c441f59415289b to your computer and use it in GitHub Desktop.
words = ['peace','piece','geese','tease','spoon']
def ham_dis(word1, word2):
return sum(c1 != c2 for c1, c2 in zip(word1, word2))
output = [
[ 'Ham-Dis', *words ],
*(
[ w1, *(ham_dis(w1, w2) for w2 in words) ]
for w1 in words
)
]
print(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment