Letter Logic

[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

 Complete this grid using the eight letters "B" through "I" so that the following four conditions are met:

  1. No column or row of the completed grid contains two vowels.
  2. No column or row of the completed grid contains two consecutive letters of the alphabet.
  3. "I" is in the middle row. "G" is not.
  4. Both "B" and "H" are in corner squares.

 

Background & Techniques

 This puzzle is from the May 2, 2018 MENSA Puzzle Calendar.  It is a hard puzzle because there is only one correct way to place the letters of the of the 40,000+ ways to do so. 

The program allows manual solving by users as well as a "Show me" button to trigger a program search.  A hint for manual solving: start with trial locations for I, G, B, and H which satisfy rules 3 and 4 since there relatively few valid locations for these letters.  The program search will search all possible letter arrangements, but gets these 4 letters placed first because checking rules 1 and 2  require searching the entire grid; a much slower process.. 

 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:

The program uses our "UCombos" unit to generate all possible ways to permute  8 items.  Each call to Combos.Getnext returns a permutation of the integers 1 to 8 in th Selected array.  Each position in the array represents a cell in the grid working left to right and top to bottom starting with the middle cell of the top row.  Each value 1 through 8 stands for a letter B through I.  Most tests can be done without actually filling the grid. For example selected[3],selected[4] and selected[5] represent the middle grid row, so to satisfy Rule 3, one of those three values must be an 8 (I) and none of them can be a 6 (G).   If either of those conditions is not met, we can stop checking and go on the next permutation.    Similar testing for B and H ensure that they are in corners. The Rule 1 single vowel test requires a scan of each row and column the grid  which I do by passing 2 (for row and column 1) or 3(other rows and columns) Selected array locations to a CountVowels function which returns the number of vowels found.   Finally, the "no consecutive" rule require checking each row and column by calling a Consecutives function which compares values in the  selected passed cell numbers looking for numbers which differ by 1 indicating that they are adjacent in the alphabet. 

All of the testing is done in an AllRulesOK function called for each permutation in the program search and also called for each final (8th) grid character entered by the user.    When users enter a character that duplicates an existing one, the program automatically removes the existing  character before adding the new one.   

 

Running/Exploring the Program 

bulletDownload  executable
bulletDownload source (Note: the UCombos unit wwith TCombos class resides in our library zip file of commonly used units.  Library file DFFVLIB13 or later is required to recompile this program )
bulletDownload current library file (DFFLibV15) required to recompile LetterLogic

 

Suggestions for Further Explorations

The "Show me" button could add one solution letter to the grid on each click as a hint to the user rather than displaying the entire solution  at once.
.
   
   

 

Original:  May 26,2018

Modified:  May 27, 2018

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