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.

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

Contact

 Search DelphiForFun.org only

Problem Description

.

This puzzle requires that you enter the digits 1 through 8 in the circles and squares (one digit in each figure) so that the number in each square is equal to the sum on the numbers in the circles which  adjoin it.

Background & Techniques

I ran across this little puzzle in a book that was one of my  Christmas gifts this year: Giant Book of Mensa Mind Challenges , Stirling Publications, 2003.  There are eight versions of the single unique solution (rotate it 90° three times, flip it over or view it in a mirror and rotate it three more times.)

The solution is not included as part of the program but if you really get stuck, it is available as a sample problem with our Brute Force problem solver which uses exhaustive search to find solutions for a given set of equations and values.

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.

Notes for programmers:

I used automatic drag and drop to allow users to drag the 8 TLabel controls (captioned 1 though 8)  to the 8 TShape controls, four circles and four squares.   I assigned the labels and shapes to arrays in order to simplify the code.   The Tag property was used assign a numeric value to a shape when a label was dropped on it.  Only a few tricky things, like remember to reset the shape's tag property to zero if a label is dragged from one shape to another.  Also if the receiving shape is already occupied (its Tag is >0), move the corresponding label back to its home starting position.

I think everything else is pretty much self explanatory.