Domino Puzzle

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




Search WWW


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 only




Problem Description

1-1   2-1   2-2   3-1   3-2   3-3   4-1   4-2   4-4   5-1   5-2   5-3   5-4   5-5

The outlines have been removed from a set of dominoes which exactly fill a  rectangular board.  Given a list of the dominoes, your task is to figure out where they belong on the board. 

Background & Techniques

This puzzle was adapted from the Giant Book of Mensa Mind Challenges, with several used copies available using the preceding link for under $2.00.   The Mensa version contains several  8X7 boards to fill.  This program allows you to select sizes from 6x5 up to 10x9.  It also allows you to "cheat" by displaying a count of the number of positions where each unplaced domino could fit on the current board.  (I haven't solved one yet without this aid, which is probably why it is there:>)  The program creates puzzles randomly  and allows you to save and restore any puzzles to/from a file.  Dominoes are placed by connecting  two numeric values on the board.   Dead ends can be correct by clicking on an in-place domino. 

 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.

The program does not yet contain a search for solutions.  A random puzzle of the selected size is created using  calls to the recursive AddDomino function.  For each cell , if not occupied, it attempts to place a domino first horizontally then vertically, calling itself to place the next one after the placement succeeds.  

There is a "Swappoint" procedure to exchange two TPoint records.  This is used in the AssignValues procedure called after the dominoes have been placed.  Each entry in the DominoValues array of TPoint records contains the two values for a domino.  For each domino on the board we randomly select a value from the part of array that has contains only unselected points.  That value is assigned to the domino and then swapped with the point at the end of the unused area. The size of the unused area is then reduced by1 so that point will not be selected again. 

Dominoes are added  to the board by mouse dragging vertically or horizontally   from one unoccupied number to a neighboring one.  Mouse-down, Mouse-move and Mouse- up even exits are used to monitor what is happening.   Clicking on an occupied area is detected in mouse down exit and the domino removed immediately.

Running/Exploring the Program 

bullet Download source
bullet Download  executable

Suggestions for Further Explorations

bullet Printing puzzle templates with solutions on a separate page for pencil and paper play. 
bullet  Calculating all solutions for a particular board.
bullet Ability to "lock" placed dominoes so that those that  "must go here"  choices will not be accidentally removed while searching for a solution.



Original Date: March 21, 2007 

Modified: May 15, 2018


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