Skip to content

Instantly share code, notes, and snippets.

@x1024
Created January 23, 2013 14:44
Show Gist options
  • Save x1024/4606950 to your computer and use it in GitHub Desktop.
Save x1024/4606950 to your computer and use it in GitHub Desktop.
Use only after consulting your conscience.
#!/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