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

```I recently received this email: Dear Delphiforfun, I have been investigating some variations on a classical problem involving pandigital fractions and wonder if you have seen solutions. Classical Problem -- I solved this one If each of the first 9 letters represents a different number--1 through 9, the smallest integer represented by: A/BC + D/EF + G/HI = 1; this assumes that the denominators are two-digit numbers and NOT multiplied. My Variations -- Need Verification of Solutions I have modified the classical equation so that the denominators are multiplied as follows: A/(B*C) + D/(E*F) + G/(H*I) and believe the smallest integral answer is 2. Can you verify that? For (A/B)*C + (D/E)*F + (G/H)*I, I think the smallest integral answer is 5. For (A/B)^C + (D/E)^F + (G/H)^I. the smallest integral answer I have found is 1,100, but I suspect there is a smaller solution. Regards, Jerry Well Jerry, assuming that you are not a programmer and were doing this by hand, 1 correct out of 3 isn't bad! ```

### ``` ``` Background & Techniques

I wrote the simple code to solve these 4 problems (the classical version and the three variations)..  I emailed the results back to Jerry,  but so far, have received no response.   Maybe he took it hard that two of his three answers were incorrect.

Each of the four uses the same technique, namely:

Generate all permutations of the digits 1 through  9.  For each permutation, assign the digits of the result in order to the 9 variables A - I and evalua6te the expression.  We'll do the evaluation in extended mode to retain fractional information.  We check that the result is and integer and if so, that it is a new  minimum before adding it to the potential solutions list.

The GetNext function from our old standby,  the Combo unit, returns the 360,000 or so permutations of the 9 digits.  Any rational numbers whose decimal representation  is an infinite repeating non-zero string cannot be represented exactly in floating point form.   To get around this problem,  we look for values that are very close to an integer (10-32 in this case).    This test and the new minimum test are incorporated into procedure CheckAndShowValues.  Procedure AssignValues assigns the permutation output to the variables.  So each solution search contains a six statement loop like this, with only the "x:=.." statement changing :

while combos.getnext do
begin
assignvalues;
x:=a/(10*b+c)+d/(10*e+f)+g/(10*h+i);  {for example}
CheckAndShowValues(x);
end;

### Suggestions for Further Explorations

 You can probably think up other expression variations to evaluate. The expressions could be selected in a radio box and a single button used to search (with a case statement to select the expression).

 Created: July 24, 2003 Modified: May 15, 2018