Created
February 7, 2022 15:14
-
-
Save md2perpe/43bc2953546ea77451c441f59415289b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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