Skip to content

Instantly share code, notes, and snippets.

@andrewdyates
Created February 16, 2014 03:22
Show Gist options
  • Save andrewdyates/9028774 to your computer and use it in GitHub Desktop.
Save andrewdyates/9028774 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
"""Let's solve a (same-length) jumble!
USAGE: python -i same_len_jumble.py
"""
MY_WORD_FILE = "/usr/share/dict/words"
anagrams = {}
for line in open(MY_WORD_FILE):
word = line.strip()
anagrams.setdefault("".join(sorted(word)),[]).append(word)
def jumbler(word):
return anagrams["".join(sorted(word))]
if __name__ == "__main__":
print "OK: jumble... now! jumbler(your_word)..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment