Word Search Generator Project


Recently, I purchased a subscription to the Chicago Tribune, and while reading over the first issue I received, I noticed that they included a word search. As the days went on, I really started to enjoy working through the puzzle.

This got me thinking about how the publishers generated the puzzle. So I decided to see if I could make my own. As a result, I am pleased to share my own word search puzzle generator! Here is a link to the GitHub repo.

The premise behind the program is simple: have users enter in a list of words, then generate a word search puzzle.

Generating the puzzle

To generate my puzzle, I had to setup a few things.

List of words

After the user enters the list of words they would like to use, the program sorts the words longest to shortest.


Words in a puzzle can have 8 directions:

Direction Visual

Puzzle Grid

Every time a puzzle is generated, you need to setup the initial puzzle grid.

To do this, I created a 2-d array and set every point in there to a NULL value.

Grid Points

My programs implements a Point class that represents a (X, Y) point on the puzzle grid.


Once the directions are set and the words are sorted, it is time to generate the puzzle.

The algorithm was pretty simple, for each word in the puzzle:

  1. Assign a random direction to the word
  2. Assign a random starting point to the word
  3. Check if the word can be inserted into the grid with its direction and starting point
    • if Yes, insert the word into the grid
    • if No, go back to step 1

How to check if word can be inserted

To check if the word can be inserted into the puzzle, there are a few things you need to examine. You will need the word itself, the starting point, and the direction.

The word cannot be inserted if any of the conditions are true:

Further reading





© 2024 by Ryan Rickgauer