Skip to content

Instantly share code, notes, and snippets.

@kevinjqiu
Created April 22, 2011 03:04
Show Gist options
  • Save kevinjqiu/935929 to your computer and use it in GitHub Desktop.
Save kevinjqiu/935929 to your computer and use it in GitHub Desktop.
hexspeak.py
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