Re:Hacking Scrabble (part 1)
by ttttannebaum on Tuesday December 13, 2011 @05:11PM
(#3349586)
In fact:
max(wordlist, key=(lambda w: intersect(w, charlist))
should replace a good portion of the create_mnemonic function. But now I'm just showing off. Just letting you know that Python is much cooler than you know.
Haskell, however, could probably do this in a few lines.
def uniqueletters(s): return set(c for c in s)
def intersect(word, charlist): return len(uniqueletters(word).intersection(charlist))