# SPUG: FW: Help..Any Math GENIUS out there?

Yitzchak Scott-Thoennes sthoenna at efn.org
Thu Jul 25 13:51:11 CDT 2002

```In article <67AC2DB52118D411A8F300508B957F120A1F2C0B at WA-MSG02>,
"Orr, Chuck  (NOC)" <chuck.orr at attws.com> wrote:
>> I am hoping to use Perl to solve an equation like the below:
>>
>> A + (36*B) + (360*C) + (3600*D) + (129600*E) = 2,307,012
>>
>> I know that each of the variables A - E is a whole number in the range
>> 1-36.
>>
>> Could I load those numbers (1 -36) in an array and substitute each number
>> for each variable until this is solved?

You could (though an array is unneccessary).  A slightly better
approach would be to compute A for all different combos of B,C,D,E and
see if it is valid (integer in 1-36).

In your example, there appears to be a relationship between the coefficients
(1 (implied), 36, 360, 3600, 129600).  If that is true in general, you can
solve it without going through all the combinations.  For instance, you
can easily find E = 17 and A = 24 in the above, leaving you with:

B + 10*C + 100*D = 2883

which has several solutions (by inspection, about 14).

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL