[Home] [Puzzles & Projects] [Delphi Techniques] [Math topics] [Library] [Utilities]
Here is a program to solve, or at least help solve, puzzles such as this one. Insert a 6 letter word into the top row of a 6x3 grid to form 6 three letter words in the vertical columns.
Background & Techniques
Here's another puzzle solver to help solve a puzzle type from our 2013 "Brain
Game" page-a-day calendar. This variety provides a 6 column x 3 row array of
letters. Row 1 is blank and rows 2 and 3 are filled with letters.
The solver's job is to find the 6 letter word for the first row which makes
valid 3 letter words in each of the 6 columns.
Puzzles from the calendar or elsewhere may be entered directly into the grid
by clicking the first cell of row 2 and entering the 12 letters which define a
puzzle, Cursor will advance from cell to cell and row to row automatically as
letters are entered.
Both the executable and source zip files include an updated large dictionary file, Full.dic, with a few additional words flagged as foreign and the word "ORC" added as it is needed to produce the correct solution of the included sample puzzle. (Yes, ORC is a real word predating Tolkien's monsters.)
Non-programmers are welcome to read on, but may want to jump to bottom of this page to download the executable program now.
Our UDict unit to access dictionary routines is the obvious vehicle to find solutions. For efficiency, two string lists are created for searching; a list of 6 letter words to get candidates when searching for solutions and also to get 2nd and 3rd row candidates when the option to use valid words there is selected while creating puzzles. A second list of 3 letter words is used to check that the the vertical columns contain valid words.
In searching for solutions, a single pass is made through the 6 letter word list. For each word, we step through the 6 letter positions, constructing a potential 3 letter word from rows 1, 2, and 3 for that column, If the "word" is not in the 3 letter word list, we move on to the the next candidate. If all 6 columns contain valid words, the solution is reported in the grid for the single solution option or in Memo1 if all solutions are being reported.
In puzzle creation mode, we are either given the row 1 solution word or choose it randomly from the 6 letter word list. If the option is set to try to fill rows 2 and 3 with valid words, we first search for a 2nd row word such that one or more 3 letter words has the first two letters in all size positions. (The Find method with return the index of the first list entry greater that the given search string. If the first two letters of W3List[index] match the the input string, then there is at least one one three letter word candidate for that column.) The 2nd row search begins at a random location a loops around so that multiple searches may generate different puzzles. When the 2nd row condition is met, an additional pass is made through the 6 letter word list looking for one which successfully completes words in all 6 columns.
If any set of letters for rows 2 and 3 will do when creating a puzzle, the job is much simpler. All we need is a 3 letter word which starts with each of the letters in the given row 1 solution word. Actually, in order to provide multiple solutions for the same solution word, we build a list of all the 3 letter words in each position and choose a random word within that list to add to the solution.
March 3, 2015:
Version 2.0 posted today reflects changes required to solve the 7 column Mensa Calendar puzzle of this type for February 13, 2015. As usual when I revisit a program, a couple more enhancements are also included.
July 23, 2017: Today's calendar puzzle led me back to this program and, as usual, exposed a bug or two. Version 2.1 corrects them and adds the puzzle to the downloads ("Mensa-Jul23_2017.wg3")
Suggestions for Further Explorations
Copyright © 2000-2018, Gary Darby All rights reserved.