Slightly off-topic: Determining the strength of "Hangman" word.
I've been playing a bit of Zynga's "Hanging with friends". I was
thinking about how to go about creating an "aid" for this. I don't
cheat, but I like solving these kinds of problems, just to prove I can.
There are two phases in Hanging with Friends. One phase is to guess the
word that your opponent has constructed, and the other phase is to
construct a word yourself.
In the construction phase, you are given a "bag" of 12 letters. I'm not
sure if its a completely random distribution. I suspect its weighted in
some way. Anyway, that's not relevant for this question.
So, It is relatively easy to write a program that uses a word list (such
the "official scrabble dictionary" word lists in the Moby collection),
to find all words in that list that can be constructed from the bag.
The problem is determining the strength of the word, how hard it is to
There is probably a psychological component to this, since the "average"
player isn't likely to use logic and will more likely just "guess"
letters that seem likely. A program (or expert) has the advantage
(somewhat) in that it can figure out statistically which letters are
most likely based on the remaining possible words, and it would then
"guess" that letter. Although I'm not certain that is actually the most
effective strategy either.
The algorithm for the "guess-ability" of a word is made more complicated
by the fact that the word itself effects how many failed guesses
opponent can have before losing the round. I'm not sure what the
algorithm is for that, though I suspect it has to do with the number of
distinct letters and word-length.
Any thoughts on algorithms or data structures you might use to solve
this kind of problem?
I've solved parts of this already. I've created "LetterBag", "Word",
"LetterSet", and "WordIndex" classes.
The WordIndex makes it easy to find "All words that match a pattern, but
don't contain letters in a specific LetterSet" and "All words that can
be made from a specific LetterBag".
Oh, and to tie this into a previous thread, the whole thing fits in
memory with room to spare ;-)