Word Grid - 3 Letter Words

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. 

     

We receive a few cents from each purchase.  Thanks

 


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa® Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa® 365 Puzzlers  Calendar 2017

Mensa® 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

 

Problem Description

 

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.

There are search buttons to find one or all solutions The multiple solution option is useful for calendar puzzles which typically have additional restrictions for the solution such as "It's a bird " for the default puzzle shown above.

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.

The "Create a puzzle" box  allows new puzzles to be generated from a solution word entered by the user or with a word chosen randomly by the program as the solution.   As a bonus, a checkbox triggers an attempt to generate puzzles with valid words in the 2nd and 3rd rows, a feature not implemented in the calendar puzzles. Common foreign words in our dictionary can optionally be included and the solution word may be hidden if the single solution option is in effect.

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.

Programmer's Notes:

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.

bulletThe program can now solve puzzles for 5, 6, o 7 columns and with any one of the three rows left blank as the solution row.
bulletIn addition, we can now create new puzzles by finding the two "hint" words for a given solution word, or create the "hint" words for a random solution word. If no hint words can be found, the program will attempt to find non-word letter-sets to create the three-letter words for each column.
bulletFinally, puzzles can now be saved and reloaded. Several sample puzzles are included in the
downloads.
 

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")  

Running/Exploring the Program 

bulletDownload  executable
bullet Download source.

Suggestions for Further Explorations

March 3 2015: Done! Fewer or more letters in rows and/or columns?   Make grid size user definable.
???
 
Original:  June 30, 2013

Modified:  May 15, 2018

  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright © 2000-2018, Gary Darby    All rights reserved.