Pierrot's 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.

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

 

Problem Description

"The Pierrot  in the illustration is standing in a posture that represents the sign of multiplication.  He is indicating the peculiar fact that 15 multiplied by 93 produces exactly the same digits (1,395) differently arranged."  The challenge is to find all possible sets of 4 digits with the same property.   The four digits may be divided into two 2-digits numbers as in the illustration, or into a single number multiplied by a 3-digit number.  

 

Background & Techniques

This fallacy is puzzle #84 from the book "Amusements in Mathematics" by H. E. Dudeney, Dover Publications.   Pierrot is a French clown/mime apparently well known to Europeans, at least back in 1917 when the book was originally published.  In his original version it was specified that all of the digits be different; I have relaxed this restriction which adds 3 solutions to the 6 that Dudeney found.     Dudeney did not consider zeros at all - allowing zeros among the digits, but not counting leading zeros in the product adds 6 more solutions.  Add finally allowing leading zeros in the product adds two more.

This program is mainly a programming exercise  since there is not much user interaction.  Clicking the Search button will list all 17 solutions.   Really not very useful unless you can find someone to bet that there are not 17 solutions and you need to show them in order to collect.  

The program has about 75 lines of user code.  Here are a couple of things that I learned (or maybe relearned) in the process of coding this program.   

A new function,  SameDigits returns true if two passed integers have the same digits  (not necessarily in the same order).  It optionally considers leading zeros in making the comparison.  I may have written a similar routine before, but one of the advantages of growing older is that we get to do lots of things over and over for the first time. 

It took a while to figure out how to display leading zeros for the outputs.  The trick is to use the "precision" specifier (the number after the decimal point) in a %d format string.  For example,  Format('%6.4d',[N]); will return integer N  right justified  into a 6 byte string and left padded with zeros out to 4 bytes.  So 12 would display as   0012 preceded by two blanks.

  Running/Exploring the Program 

Suggestions for Further Explorations

There are dozens, maybe hundreds,  of good computer program candidates in Dudeney's book.  It impresses me that he could invent, and solve so many without a computer to help!

Original Date: October 5,  2002

Modified: February 18, 2016

 

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