Skip to content

Instantly share code, notes, and snippets.

@mjard
Created December 7, 2011 14:26
Show Gist options
  • Save mjard/1442990 to your computer and use it in GitHub Desktop.
Save mjard/1442990 to your computer and use it in GitHub Desktop.
from collections import defaultdict
from itertools import combinations
worddict = defaultdict(list)
letters='sillystring'
for word in file('/usr/share/dict/words'):
w = word.strip().lower()
worddict["".join(sorted(w))].append(w)
def find_words():
for n in range(len(letters),0,-1):
for p in combinations(letters, n):
results = worddict["".join(sorted(p))]
if results:
return results
print find_words()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment