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
|Created August 13, 2013
February 18, 2016