[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Cookbook Inspired Equation Solver.



>> "A" == Alistair McGlinchy <Alistair.McGlinchy@marks-and-spencer.com> writes:
A> The original question was to find unique digits A,B, ..., I between 1 and 9
A> such that ABCD / EFGHI = 1 / 66.  I think the best result from this game was
A> written as:
A> perl -le"print grep{($_.$_*66)!~/(.).*\1|0/}1e3..1e4"

A> Anyway below is some code which will solve this any of those silly equations
A> for you.

I'm not positive what you mean by "any of those silly equations", but
looking at your code you might mean "for any number of digits in the
numerator up to 9" this returns all solutions.

perl -le'$,="\n";print grep{($_.$_*66)!~/(.).*\1|0/}10**$_..10**($_+1) for 0..3'

But judging by the output of your program, which is essentially no
different than the original one-liner, you probably mean something
else. Could you please clarify?

Hope you have a very nice day, :-)
Tim Ayers (tayers@bridge.com)
Norman, Oklahoma


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe