Calculator Keys Puzzle

[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

The young math professor noticed one day that this subset of his calculator's keys could be read as an equation, but not a valid one:   
But by exchanging a couple of pairs of numeric keys he could make the equation valid.  Can you find the 2 pairs of keys that he swapped?

Background & Techniques

Another puzzle from the Giant Book of Mensa Mind Challenges  book.  Click on pairs of keys until a true equation is formed.   There are 1296 ways to swap two pairs of keys, 36 ways for each pair, so 36x36=1296 ways altogether.   (There are 9 times 8 (72) choices for each pair, but since swapping a with b is identical to swapping b with a and they are both included in the 72, we must divide by 2, resulting in 36 unique pair swaps of the 9 keys).

I'll admit that I never did solve the puzzle manually in any number of swaps.  But a search of all 1296 possibilities although quite time consuming for us, is trivial for the computer.  So in addition to clicking on the keys to swap them, I added a Solve button for the lazy.   

There are about 150 lines of user code in the program, about half to handle user clicks and half for the solve search procedure.  Function CheckAns checks the keys to see if the equation is satisfied.   The keys themselves are TButton controls put into an array for easy referencing. Keys are swapped by simply exchanging their caption and tag values within the array.   I included two standard wave files in the zipped files, just incase they are missing from a particular system.   "Balloon.wav" is a fairly unobtrusive error sound when the equation after a swap is false. "Tada.wav" is the reward for a valid solution.

Running/Exploring the Program 

bullet Download source
bullet Download  executable

Suggestions for Further Explorations

Are there solutions requiring 3 or more pair swaps? 

 

Created: April  9, 2006

Modified: July 29, 2017

 

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