SPUG: FW: Help..Any Math GENIUS out there? (SPOILER)

Mark Yocom myocom at winse.microsoft.com
Thu Jul 25 16:21:39 CDT 2002


This can be done iteratively rather than using just brute force.  What
you really have here is just a different counting system.

Given:
A + (36*B) + (360*C) + (3600*D) + (129600*E) = 2,307,012

Rewrite this as:
2307012 = 129600*E + 3600*D + 360*C + 36*B + A

...and it starts to look analogous to this sort of thing:

12345 = 10000*1 + 1000*2 + 100*3 + 10*4 + 1*5

This is easy to derive because we have a nice decimal system that has
predictable columns like "ones", "tens", "hundreds", etc.  In the case
of this problem, though, we have columns of "ones", "thirty-sixes",
"three-hundred sixties", "thirty-six hundreds", and "one hundred
twenty-nine thousand six-hundreds" (phew!).  So even though those are
goofy columns, you can still solve it the same way:

2307012 = 129600*E + 3600*D + 360*C + 36*B + A
int(2,307,012 / 129600) = 17, so E must be 17 (there are 17 129600's)
2307012 - 129600*17 = 103812 (our new total)

103812 = 3600*D + 360*C + 36*B + A
int(103812 / 3600) = 28, so D must be 28 (there are 28 3600's)
103812 - 3600*28 = 3012 (new total)

3012 = 360*C + 36*B + A
int(3012 / 360) = 8, so C must be 8 (there are 8 360's)
3012 - 360*8 = 132 (new total)

132 = 36*B + A
int(132 / 36) = 3, so B must be 3 (there are 3 36's)
132 - 36*3 = 24

24 = A, and there you have it.

A = 24
B = 3
C = 8
D = 28
E = 17


> -----Original Message-----
> From: Pommert, Daniel [mailto:Daniel.Pommert at verizonwireless.com] 
> Sent: Thursday, July 25, 2002 12:43 PM
> To: 'Orr, Chuck (NOC)'; 'spug-list at pm.org'
> Subject: RE: SPUG: FW: Help..Any Math GENIUS out there?
> 
> 
> This is an integer programming problem.  But if you look at 
> it, you see that E can only be values from 1 through 17.  You 
> don't care about the value of
> A: it will be whatever it needs to be.  So, you could do a 
> simple exhostive search for solutions by looping through the 
> 36 * 36 * 36 * 17 values of B, C, D, and E (respectively).  
> This shouldn't take more than a couple seconds of computer 
> time and could be written in under 20 lines of code.
> 
> -- Daniel Pommert 
>   Verizon Wireless
>   425-603-8612
> 
> -----Original Message-----
> From: Orr, Chuck (NOC) [mailto:chuck.orr at attws.com]
> Sent: Thursday, July 25, 2002 10:51 AM
> To: 'spug-list at pm.org'
> Subject: SPUG: FW: Help..Any Math GENIUS out there?
> 
> 
> 
> 
> > Hello,
> > 
> > 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?
> > 
> > Any ideas would be greatly appreciated.
> > 
> > 
> > Thanks,
> > Chuck Orr
> > AT&T Wireless Services
> > 425 288 2386
> > chuck.orr at attws.com
> 
>  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
> - - - - - - -
>      POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
>       Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
>   Replace ACTION by subscribe or unsubscribe, EMAIL by your 
> Email-address  For daily traffic, use spug-list for LIST ;  
> for weekly, spug-list-digest
>      Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
> 
>  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
> - - - - - - -
>      POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
>       Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
>   Replace ACTION by subscribe or unsubscribe, EMAIL by your 
> Email-address  For daily traffic, use spug-list for LIST ;  
> for weekly, spug-list-digest
>      Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
> 
> 

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list