Skip to content

Instantly share code, notes, and snippets.

@mcenirm
Created February 1, 2014 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcenirm/8753132 to your computer and use it in GitHub Desktop.
Save mcenirm/8753132 to your computer and use it in GitHub Desktop.
from itertools import permutations
WORD_FILE = '.../words'
words = set(x.strip() for x in open(WORD_FILE).readlines())
LETTERS = 'abcdefg'
perms = set((''.join(x).split())[0] for x in permutations(LETTERS+' '))
matches = list(perms.intersection(words))
matches.sort(key = len, reverse = True)
print matches[:10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment