Word Search By Column

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




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


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

Search DelphiForFun.org only




Problem Description

 Here's an interesting puzzle requiring the player to choose one letter fro each row in a 5x5 letter grid from top to bottom to form five 5-letter words. Each letter will be used exactly once, and each letter position the a word must come from the corresponding row of the grid.

Background & Techniques

 The puzzle is adapted from the July 29, 2017 Mensa Page-a-Day calendar.  In play, you may jump to any column to choose he next letter in your word as you go down. There is no need to rearrange the letters and every letter will be used exactly once. The clue for this puzzle from the the original calendar specifies that  all of the words describe items with stems.  

The clue was not at all helpful for the programmed solution search presented here. It does find two solutions, only one of which has all "stemmed" items. There are 5x5x5x5x5 (3,125) ways to select the letters but, of those, only 28 are words in our dictionary. The first button finds the 28 words. The second button finds the 5-word subsets of these which cover all 25 letters - defined solution conditions.

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:

This is one of the more difficult recursive search  based programs I've tackled because the search is mult-level.  Not only must we find letters to build candidate words, but also find a sub-set of words that use all letters.   After a week of work trying accomplish both tasks in a common "find" function I went back to the "divide and conquer" strategy by separating the two tasks. 

bulletThe "Find possible solution words"  button builds a list of all words which start with one of the first row letters and contain a letter from each of rows 2 through 5 for word  letters 2 through 5 respectively.   Of the 55 possible words, there are only 28 candidates meeting the above conditions. it uses a recursive "GetNextLetter"  routine to generate the words to test.
bulletThe "Search for Solutions" button recursively calls the "GetNextWord" function to find 5 word subsets from the 28 which cover all five grid row letters with letters from the corresponding word letter positions. 

Much easier - "Divide and Conquer" works again!

The only other item worth mentioning is use of the library routine  IgnoreSelectedDrawCell method in a OnDrawCell exit to remove the  default highlighting of the currently selected cell.

Running/Exploring the Program 

bullet Download executable
bullet Download source (Note: program requires rouitnes residing in our library zip file of commonly used units.  Library file DFFVLIB15 or later is required to recompile this program )
bullet Download current library file (DFFLibV15) required to recompile this program.


Suggestions for Further Explorations

Allow interactive user play


Original:  August 19. 2017

Modified:  May 12, 2018


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