Created
January 23, 2013 14:44
-
-
Save x1024/4606950 to your computer and use it in GitHub Desktop.
Use only after consulting your conscience.
This file contains hidden or 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
#!/bin/env python2.7 | |
#-*- coding:UTF-8 -*- | |
import sys | |
import collections | |
letters = collections.Counter(list(''.join(sys.argv[1:]))) | |
words = [word.strip() for word in open('/usr/share/dict/words').readlines() | |
if word.find("'") == -1] | |
def matches(word, letters): | |
return (len(collections.Counter(word) - letters) == 0) | |
possible = [word for word in words if matches(word, letters)] | |
print letters | |
print list(reversed(sorted(sorted(possible), key=len))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment