Re: Arithmetic Puzzle (so simple it's hard)
- To: mathgroup at smc.vnet.net
- Subject: [mg71590] Re: Arithmetic Puzzle (so simple it's hard)
- From: "Dana DeLouis" <dana.del at gmail.com>
- Date: Fri, 24 Nov 2006 01:17:09 -0500 (EST)
Here's a solution similar to Scott's. Note the unit digit (T) in FEAST. It is derived from k*t from the other two words. Therefore, Mod[k*t,10] must equal t. We can use this simpler test to eliminate choices before we apply a more complex test. p = Permutations[{0, 1, 2, 4, 5, 6, 7, 9}]; Length[p] 40320 We can eliminate about 3/4 of the possible solutions based on the unit digit. p2 = Select[p, Mod[Times @@ #1[[{5, 7}]],10] == #1[[7]] & ]; Length[p2] 12240 m1 = {100, 10, 1}; m2 = {10000, 1000, 100, 10, 1}; Test[x_] := x[[{2, 8, 7}]] . m1*x[[{1, 6, 5}]] . m1 == x[[{4, 3, 1, 6, 7}]] . m2 Select[p2, Test] {{1, 6, 5, 9, 2, 4, 0, 7}, {4, 0, 7, 2, 1, 9, 6, 5}} We don't want a 0 in positions 1,2, or 4, so we eliminate the second solution. -- HTH :>) Dana DeLouis Windows XP, Mathematica 5.2 "Bruce Colletti" <vze269bv at verizon.net> wrote in message news:ejc4pv$6nf$1 at smc.vnet.net... > How would this problem be solved in Mathematica? > > BUT * ASK = FEAST, where each letter is a 1-digit number, no two letters may stand for the same number, and the letters are in {0,1,2,4,5,6,7,9}. > > Thankx. > > Bruce >