[Home] [Puzzles & Projects] [Delphi Techniques] [Math topics] [Library] [Utilities]
|
|
Problem Description
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 :
Running/Exploring the Program
Suggestions for Further Explorations
|
[Feedback] [Newsletters (subscribe/view)] [About me]Copyright © 2000-2018, Gary Darby All rights reserved. |