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

Can Subaykan cansubaykan at hotmail.com
Thu Jul 25 16:55:25 CDT 2002


How long did that take you to run?  This was my first idea, I was going to 
do like this, but after I got an idea of how long this was going to take, I 
decided to control-C and wait for math PhD perl programmers to respond to 
the question.

@a = @b = @c = @d = @e = (1..36);
$sols=0;

for $a (@a) {
  for $b (@b) {
    for $c (@c) {
      for $d (@d) {
        for $e (@e) {

           print "trying $a $b $c $d $e\t$sols solutions\n";

	   if ($a + 36*$b + 360*$c + 3600*$d + 129600*$e == 2307012) {

              print "A = $a, B = $b, C = $c, D = $d, E = $e\n";
              $sols++;

           }

        }
      }
    }
  }
}

print "\n\n$sols solutions\n\n";




----Original Message Follows----
From: "Duncan McGreggor" <oubiwann at myrealbox.com>
To: chuck.orr at attws.com
CC: spug-list at pm.org
Subject: Re: SPUG: FW: Help..Any Math GENIUS out there?
Date: Thu, 25 Jul 2002 16:38:06 -0400

Man, it's been a really long time since linear algebra... but I think that 
since you don't have 5 equations (to go with your 5 vars), you can't solve 
it with a matrix...

It's not a quad, cubic, etc., so you can't solve it with those methods...

What about brute forcing it:

for ($a=1;$a<=36;$a++) {
  $A=$a;
  for ($b=1;$b<=36;$b++) {
   $B=36*$b;
   for ($c=1;$c<=36;$c++) {
    $C=360*$c;
    for ($d=1;$d<=36;$d++) {
     $D=3600*$d;
     for ($e=1;$e<=36;$e++) {
      $E=129600*$e;
      if ( $A + $B + $C + $D + $E == 2307012 ) {
       print "found a solution:\n\t$a, $b, $c, $d, $e\n";
      }
     }
    }
   }
  }
}

I don't know if my math is right, but I got the following results:

found a solution:
         24, 3, 8, 28, 17
found a solution:
         24, 3, 18, 27, 17
found a solution:
         24, 3, 28, 26, 17
found a solution:
         24, 13, 7, 28, 17
found a solution:
         24, 13, 17, 27, 17
found a solution:
         24, 13, 27, 26, 17
found a solution:
         24, 23, 6, 28, 17
found a solution:
         24, 23, 16, 27, 17
found a solution:
         24, 23, 26, 26, 17
found a solution:
         24, 23, 36, 25, 17
found a solution:
         24, 33, 5, 28, 17
found a solution:
         24, 33, 15, 27, 17
found a solution:
         24, 33, 25, 26, 17
found a solution:
         24, 33, 35, 25, 17



Duncan


-----Original Message-----
From: "Orr, Chuck  (NOC)" <chuck.orr at attws.com>
To: "'spug-list at pm.org'" <spug-list at pm.org>
Date: Thu, 25 Jul 2002 10:50:52 -0700
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




_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.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




More information about the spug-list mailing list