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.
To generate my puzzle, I had to setup a few things.
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:
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
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:
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:
© 2023 by Ryan Rickgauer