Last active
December 12, 2015 07:39
-
-
Save kierendavies/4738488 to your computer and use it in GitHub Desktop.
finds words which are mirror-image palindromes in elian script
This file contains 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
#!/usr/bin/python3 | |
# find words which are mirror-image palindromes in elian script | |
with open("/usr/share/dict/words", encoding="utf-8", errors="ignore") as fin: | |
words = [word.strip().lower() for word in fin.readlines()] | |
sub = {'i': 'c', 'h': 'b', 'k': 'q', 'j': 'p', 'm': 'm', 'l': 'r', 'o': 'o', 'n': 'n', 'a': 'g', 'c': 'i', 'b': 'h', 'e': 'e', 'd': 'd', 'g': 'a', 'f': 'f', 'y': 's', 'x': 'x', 'z': 't', 'q': 'k', 'p': 'j', 's': 'y', 'r': 'l', 't': 'z', 'w': 'w', 'v': 'v'} | |
for word in words: | |
subbed = "" | |
for l in word: | |
if l not in sub: continue | |
subbed += sub[l] | |
if subbed == word[::-1]: | |
print(word) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment