MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Arithmetic Puzzle (so simple it's hard)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71627] Re: Arithmetic Puzzle (so simple it's hard)
  • From: croddie at princeton.edu
  • Date: Sat, 25 Nov 2006 05:37:08 -0500 (EST)
  • References: <200611141006.FAA06684@smc.vnet.net><ejtda3$isg$1@smc.vnet.net>

Janos: get used to functional programming!

Simple program, not too slow; plus you can read and understand it:

doesitwork[partition_] :=
     Module[{b, u, t, a, s, k, f, e},
                {b, u, t, a, s, k, f, e} = partition;
                (100b + 10u +t)(100a + 10s + k) == 10000f + 1000e +
100a + 10s + t];
Timing[Select [Permutations[{0, 1, 2, 4, 5, 6, 7, 9}], doesitwork]]

Output:
{1.578 Second, {{0, 5, 6, 4, 9, 1, 2, 7}, {6, 7, 0, 1, 4, 2, 9, 5}}}


János wrote:

> Any suggestions to make it faster would be highly appreciated.  /It
> took 526 seconds to run with above parameters/
>
> János
> On Nov 14, 2006, at 5:06 AM, Bruce Colletti wrote:
> 
> > How would this problem be solved in Mathematica?


  • Prev by Date: Numerical vaule of multinormal distribution
  • Next by Date: Re: Non-linear Rgression
  • Previous by thread: Re: Re: Arithmetic Puzzle (so simple it's hard)
  • Next by thread: Re: Re: Arithmetic Puzzle (so simple it's hard)