Printable PDF Wordsearch Puzzles



The wordsearch generator was written in C++, and uses the libpng, cairo, cgicc, db, and pthreads libraries, and the flock function. A little bit of hacking may be required to get it to compile on your platform.

The source code may be downloaded, modified, and distributed under the terms of the GNU Public License. It has been documented with Doxygen.

Download: source.7z

Console Version

If you can manage to compile the source, you will have access to a command line version of the generator. If executed without arguments, it prints the following message to stderr:

Usage: ./console [options] word1 [word2 [...]]
  -h -? --help     Display this message
  -t --title       Set puzzle title
  -f --field       Add a field to the puzzle, such as name or date.
  -o --output      Set output PDF filename.
                   Writes a text version to stdout if omitted.
  -s --size        Set page size in points, defaults to 612x792.
  -m --mask        Specify a PNG image to use as the puzzle shape.
                   White/transparent portions of the image remain blank.
                   Uses a square mask if omitted.
  -d --dir         Specify a list of word directions, of:
                   Defaults to all directions if omitted.
  --               Interpret remaining options as words.
  ./console -s792x612 --title=Xyzzy -fName -fDate -d r,d -o puzzle.pdf -- Hello World


First, a pool of potential puzzles is created. It is initially populated with a single element, the empty puzzle.

The generator then sorts the words by their difficulty. The letters from all the words to be added are collected together and the probability of a given letter in that collection being selected at random is calculated. For the letters of each word, their probabilities are multiplied together to determine that word's difficulty.

For each word, in order of most difficult to least difficult, that word is added to every valid position of every puzzle in the pool. If the pool is empty, the generator starts over again with a slightly larger puzzle size. The best 8192 results then replace the pool and are used as the pool for the next word. The value of a puzzle in this case is determined by the number of letters in the puzzle, with fewer letters indicating more intersecting words.

When there are no remaining words, the pool is left containing potential solutions. For each puzzle in the pool, in order of best to worst, that puzzle is verified to ensure that each word appears exactly once. If such a puzzle is found, it is used as the solution and generation is complete. If no such pool is found, the generator starts over with a slightly larger puzzle size.

Filling the puzzle with random letters is deferred to the rendering stage, and not part of puzzle generation. When the puzzle finally is filled, however, it attempts to match the frequency of the letters already in the puzzle without creating duplicates of the words in the puzzle. 128 attempts are made, after which it falls back to using an even distribution of all 26 letters.