Word Games

Perl is a great language for coding solutions to many types of word games (actually it is just a great language). Here we provide a brief description of some of the word games we provide solutions for. The perl scripts are available for download. We also provide an online, cgi based server running these scripts. This server is a PII 266 running Linux of course. Note that the cgi version runs at low priority and I do use it for real computations. If you really want to have fun you should grab the scripts yourself and play with them at your leisure. You need to provide your own dictionary. The small dictionary we use is just /usr/dict/words that should be on all unix type boxes.

These scripts are provided by Craig J Copi and Peter Kernan.


This is the name we have given to the game where you try to get from one word to another in a fixed number of steps by only changing one letter at a time and producing a valid word at each step. For example the one solution (in our small dictionary) to get from loss to gain in 6 steps is

You can grab the Toggle script yourself or try it out online if you like.

This script has evolved quite a bit from the original brute force approach. I tried to run the original script on loss to gain in 10 steps and ended up killing it after 3 hours of searching and not finding a solution. Putting a little bit of thought into the algorithm and pruning the search tree the current version will find all 20,000 solutions (in the small dictionary) in about 6 minutes.


This is the type of puzzle that appears in many newspaper puzzle sections. Finding solutions is very easy in Perl. In fact, it takes more time to read in the dictionary than it does to find solutions (hashes are good things). We are still finishing up the script for this one. It should appear soon.

Diagramless Crossword Puzzles

It turns out that good crossword puzzles follow a strict set of rules regarding the structure of the puzzle. Because of this just from the list of numbers of the across and down clues you can reconstruct the puzzle. Of course it is frequently the case that the puzzle isn't unique. For 15x15 square puzzles there maybe a few possible solutions usually with regards to where the black squares appear near the middle of the puzzle. So it still helps to be able to fill in some of the words.

I have some C code I wrote a long time ago to do this. It is currently not available and if I ever get some time I may try to resurrect it (and maybe rewrite it in perl). If you can't live without this program feel free to email me.

CJCCopyright © 1998, Craig J Copi

Valid HTML3.2 Html 3.2 Final DTD . . . valid!