Time for Words

Like many of my projects, this program started as an idle daydream, me wondering how easy it would be to write a solver for this type of game. Fifteen minutes later, I had a pretty nifty recursive algorithm that, given a set of letters, generated every single word those letters could combine to form.

And thatís a lot of words. Assuming certain things (some of which arenít always true, but this wasnít bad for fifteen minutes of mostly in-my-head math), 6 letters could form 720 different words, most of which are not valid. Thatís not huge, but the combinations grow fast: 8 letters result in 40,320 words (again, mostly invalid words). 12 letters can form 479,001,600 words! To compare, the dictionary this program uses contains 178,590 total valid words.

Which means that my nifty recursive algorithm pretty quickly ran out of memory when dealing with those longer letter strings. This is actually a case where taking a dumber approach was actually better- the final algorithm simply iterates over the dictionary just once, checking whether each word can be formed by the supplied letters. Not too smart, but it actually works better than my original algorithm.

From that second algorithm, this game was born. It was pretty fun to tweak the rules to ďinspireĒ the feel I was going for and come up with the final result.

Anyway, if I wanted to spend more time on this, I would probably play with the idea of using longer letter strings instead of limiting it to six each time- or I could eliminate much of the dictionary, improving the initial load time. But since itís not that bad anyway, Iím not too worried about it.

If you wanted to play with the source, it might be interesting to use different dictionaries- replacing the dictionary with, say, a Spanish one, is as easy as replacing a single text file and changing a single line of code.