You are given a square letter grid with a
single word occupying the first row and column. You are also given
a set of letters to be used in completing the grid with intersecting
words. Each word will occur horizontally and vertically in the row and
column of the same number.
At right is a partially completed 4x4 grid with the
"Used letter" grid below it showing that 1 "E", 1 "F", and 2 "T"s need to be
entered to complete the puzzle. .
Background & Techniques
This type of puzzle occurs several times in each
year's Mensa Page-A-Day Puzzle Calendar. They are usually not too
difficult, but curiosity led me to try my hand at generating them. The
result is this puzzle program which creates 4x4 or 5x5 puzzles based on our
medium size dictionary. (The largest dictionary generates too many
puzzles with words that most normal humans have never heard of.)
Click the New Puzzle button to generate a random
puzzle which will display the grid with the first word filled in. As
you click each square and enter a letter, the word grid and a second grid of
the letter counts will be updated. You may enter any
valid letter in any square whether occupied or not in any cell except the
first row or column, The "Restart" button allows
the user to reset letters and statistics for the current puzzle.
Finally, the "Give Up button will display the solution that the
Non-programmers are welcome to read on, but may
want to skip to the bottom of this page to download
executable version of the program.
Notes for Programmers
Our dictionary unit is used to generate the words
for the puzzle. For efficiency, all words of the desired
length are extracted to a TStringList named List. The
initial word is selected randomly and a call made to the recursive
FIndNextWord function to fill in the rest of the words.
FindNextWord tries up to 1000 random words to find one which
would fit with the preceding words already selected. After 1000 tries,
we resort to a sequential search through the list looking for qualifying
words. The idea of random selection is to increase the number of
puzzles generated even when the initial word has been used in a previous
Words as found are kept in a array, of
strings W. The initial word is placed the TstringGrid,
Lettergrid. A second TStringgrid, StatsGrid, contains 3
rows of available letters, the available count for each letter, and
the count of times that letter was entered by the user.
Lettergrid has an OnKeyPress exit which
handles each user click. Only letters from the valid
letter set are allowed and they may be be placed in the 1st column or row.
Letters off of the diagonal are automatically duplicated in the
corresponding position on the other side of the diagonal. After each letter
is placed, the letter counts in the Statsgrid are updated, and if all
letters have been used, a check is made for a valid solution. In
testing, I found cases where the solution was not unique. The posted
version checks the users words against the list of all words as well as
against the solution found by the program. Credit for solving is given
for solutions, whether or not they match the one found by the program,
however in the "new solution" case, the user is informed that there is more
than one solution. .
Running/Exploring the Program
Suggestions for Further Explorations
A useful option would be to allow user to select
the dictionary to use. The current dictionary, General.dic is
medium sized and has only a couple of thousand 4 letter words. Those
with an initial vowel must be quite limited, since I tend to see "AREA",
"IRIS", and "OKRA" with greater frequency than one would expect.
Perhaps a version with more of these initial-vowel words should be
generated. (The full dictionary has too many esoteric words to be fair
or fun for the player. but there are probably many common words that
could augment the word list used .)
A better reward for success would be nice.
Sound or visual effects are good but tend to increase program size
significantly. A serious version of the program might allow the
user customize the type and specific files used for rewards.
Original Date: December 01, 2006
July 29, 2017