### 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

 Pandigital numbers contain all of the digits 0 through 9 exactly once. "Almost pandigital" numbers contain no zeros and the digits 1 through 9 exactly once.

As an introduction to pandigital numbers, write  a program that finds:

1. The smallest pandigital number that is a perfect square.
2. A number and it's square which together contain digits 1 through 9 exactly once (i.e. form an "almost pandigital" number.

1.  Find a pandigital number in which each subset of the first N digits considered as an integer is exactly divisible by N.  (For example. the number cannot be 1234567890 because even though "1" is divisible by 1, "12" is divisible by 2, and "123" is divisible by 3, "1234" is not divisible by 4.)
2. Find all equations of the form a x b = c with the property that a, b, and c are integers and collectively they form an almost pandigital number, i.e. they contain the digits 1 through 9 exactly once.
3. Find all almost pandigital numbers, using digits 1 thru 9 only once each, with the property that its square contains each digit 1 thru 9 twice.

Addendum May 31, 2010:  Version 3.1 adds one more problem today.  This solves the problem posed by Listener Crossword #4088, "Digimix".  It seems that "Listener" crossword puzzles are published weekly in the London Times which charges for current puzzles (!) but are available for free after a few weeks at www.ListenerCrosswords.com.

1. Find integers X and Y which together form an Almost pandigital number (X and Y together contain only the digits 1 through 9 exactly once) and the sum of whose squares(X2 + Y2) is also Almost pandigital.

### Background & Techniques.

Both problems depend on generating pandigital numbers in increasing sequence.   Function GetNextPandigital performs this job for us.   It uses the Sawada/SEPA  permutation algorithm introduced in Permutes1.

Some definitions of pandigital specify that it cannot begin with 0, others do not and I haven't found an "official" definition.  In solving the first problem, I added a checkbox that lets the user decide if leading zeros count.  Allowing a leading zero,  the smallest pandigital is 0123456789;  without a leading zero the smallest is 1023456789.