SPUG: FW: Help..Any Math GENIUS out there?
doug at beaver.net
Thu Jul 25 17:02:16 CDT 2002
On Thu, Jul 25, 2002 at 10:50:52AM -0700, Orr, Chuck (NOC) wrote:
> > 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.
I would take a different approach from Daniel's. He is looking at the
variables and reducing the number of moving parts in the calculation,
but it's not a generic solution. Is the equation you mentioned the one
you really want to solve or just an example? I'm assuming it's an
example. You'll have a heck of a time writing code to do what Daniel is
doing, he has the advantage of being a human and being able to
understand algebraic expressions. Perl doesn't have either of those
things working in it's favor. :-)
I would suggest that you instead look on search.cpan.org and search for
modules starting with Math::. Or perhaps there is an existing C/C++
library you can wrap with SWIG or XS to get the functionality into your
perl scripts. I'm positive there are C/C++ libraries that already do
this, and I wouldn't be surprised if there was a CPAN module that did so
as well... This is moot if that is the only equation you want to solve
and you're sure it will never change, but things rarely work out that
Space Ghost: Moltar, I have a giant brain that is able to reduce any
complex machine into a simple yes or no answer.
Moltar: Okay, but that's not the cd burner...
Space Ghost: Moltar! <pause> Yes!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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