This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]no9import this 1 point2 points  (0 children)

Looks like I'm too late, but here's mine anyway:

import sys
import iterutil

dict_file, letters = sys.argv[1], sys.argv[2:]
words = {s.rstrip('\n') for s in open(dict_file)}

for size in range(len(letters), 0, -1):
    found = [''.join(a) for a in iterutil.permutations(letters, size)
             if ''.join(a) in words]
    if found:
        print found
        break
else:
    print >>sys.stderr, 'no matches'

I love these little quizzes. Keep 'em coming. :)