Skip to content

Instantly share code, notes, and snippets.

@DeadWisdom
Created December 7, 2011 10:07
Show Gist options
  • Save DeadWisdom/1442246 to your computer and use it in GitHub Desktop.
Save DeadWisdom/1442246 to your computer and use it in GitHub Desktop.
Scrabble.py
def scrabble(dictionary_path, letters, max=10):
results = []
letters = set(letters)
for word in open(dictionary_path):
word = word.strip()
if letters == set(word):
results.append(word)
results.sort(key=len)
results.reverse()
return results[:max]
if __name__ == '__main__':
import sys
for word in scrabble(sys.argv[1], sys.argv[2:]):
print word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment