Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
finds words which are mirror-image palindromes in elian script
#!/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
You can’t perform that action at this time.