Created
April 22, 2011 03:04
-
-
Save kevinjqiu/935929 to your computer and use it in GitHub Desktop.
hexspeak.py
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
def words(): | |
with open('/usr/share/dict/words', 'r') as f: | |
return (x.strip().upper() for x in f.readlines()) | |
MAPPING = {'A':'A', 'B':'B', 'C':'C', 'D':'D', | |
'E':'E', 'F':'F', 'O':'0', 'S':'5', 'I':'1'} | |
def main(): | |
is_hexword = lambda word: all(ch in MAPPING for ch in word) | |
for word in filter(is_hexword, words()): | |
print word, "\t", ''.join(MAPPING.get(ch, ch) for ch in word) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment