Challenging Math Teasers

[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




Here are three problems from the 100 presented in the "Challenging Mathematical Teasers" book by J.A.H. Hunter  and published by Dover Publications. These puzzles generally require math techniques beyond simply solving an algebraic equation or two. The three presented here were chosen randomly are easily amenable to programmed solutions (and have relatively short descriptions :>).  By the way, the above link to Amazon offers a number of good used copies of this book for $0.01 + $3.99 shipping,  if you reside in the U.S.

This is a one day effort while taking a break from the "Find All Polygons" program I have been wrestling with for the past two weeks.   Who knew polygons could be so hard to find?

I placed this program in the Math Topics section of DFF but also indexed it under Delphi Techniques and Beginners categories since it does illustrate some useful number manipulation techniques with less than 20 source code statements to handle each of the 3 problem buttons.  

The problems are:

#47: Grandfather's Birthday

"Don't be late now", said Susan. Your grandfather's coming over. It's his birthday, you know." Doug nodded. "Sure, and I made up  something on his age. If you add up all the ages I've been , including my age now, you get one year more than his age," he replied. "And the total of the two figures of his age is my age."

What are the two ages? (The program finds several solutions, but probably only one with a feasible age for grandpa.)

#44: A Matter of Squares

Charlie stopped outside the entrance. "Anyway it does have an interesting number." he commented. Quite unique in fact.." "Looks very ordinary to me" George shook his head. "But you know how I am about figures."  "Deplorable in a man of your age!' Charlie smiled. "But I'll tell you. If you total the squares of its three digits, you'll get exactly half that number."

What was the number? (Fewer than 10 lines of code required to solve this using "mod" and "div" operators to extract and test the digits of a bunch of 3 digit even numbers.)

#24: Wrong but Right

Wendy watched with growing impatience as the clerk made out the check for her purchases. "Say!" she exclaimed at last. You multiplied the three amounts instead of adding them. That's crazy!". "Sure I did, but it's okay." the young man replied. "The total comes to $5.70 either way. Add them up yourself." Indeed, he was right.

What were the individual amounts? (Program needs a few tricks to allow calculations in cents using integer arithmetic. Floating point is more problematic since there is no exact binary representation for any multiple of 10, thus requiring a "close enough" test when
comparing the product to the target.)


 Running/Exploring the Program 

bullet Download source
bullet Download  executable


Created August 13, 2013

Modified May 11, 2018



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