[Date Index]
[Thread Index]
[Author Index]
Re: Arithmetic Puzzle (so simple it's hard)
*To*: mathgroup at smc.vnet.net
*Subject*: [mg71321] Re: Arithmetic Puzzle (so simple it's hard)
*From*: Scott Hemphill <hemphill at hemphills.net>
*Date*: Wed, 15 Nov 2006 06:43:11 -0500 (EST)
*References*: <ejc4pv$6nf$1@smc.vnet.net>
*Reply-to*: hemphill at alumni.caltech.edu
Bruce Colletti <vze269bv at verizon.net> writes:
> 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}.
Represent the possible solutions by a list x, where
x[[1]] is the value for "A"
x[[2]] is the value for "B"
x[[3]] is the value for "E"
x[[4]] is the value for "F"
x[[5]] is the value for "K"
x[[6]] is the value for "S"
x[[7]] is the value for "T"
x[[8]] is the value for "U"
A function which tests whether the list x satisfies the condition
BUT * ASK = FEAST looks like:
In[1]:= test[x_] := {100, 10, 1} . {x[[2]], x[[8]], x[[7]]}*
{100, 10, 1} . {x[[1]], x[[6]], x[[5]]} == {10000, 1000, 100, 10, 1} .
{x[[4]], x[[3]], x[[1]], x[[6]], x[[7]]}
This function returns True if the condition is satisfied, otherwise False.
To solve the problem just select the permutations of {0,1,2,4,5,6,7,9} which
satisfy the test:
In[2]:= Select[Permutations[{0,1,2,4,5,6,7,9}], test]
Out[2]= {{1, 6, 5, 9, 2, 4, 0, 7}, {4, 0, 7, 2, 1, 9, 6, 5}}
You might want to exclude the second solution because it sets "B" to 0.
In[3]:= Select[%, #[[2]]!=0&]
Out[3]= {{1, 6, 5, 9, 2, 4, 0, 7}}
This list corresponds to 670 * 142 = 95140.
Scott
--
Scott Hemphill hemphill at alumni.caltech.edu
"This isn't flying. This is falling, with style." -- Buzz Lightyear
Prev by Date:
**Vandermonde Matrix/Optimization question**
Next by Date:
**Re: finding the (v,w) weighted degree of a polynomial**
Previous by thread:
**Re: Arithmetic Puzzle (so simple it's hard)**
Next by thread:
**Re: Arithmetic Puzzle (so simple it's hard)**
| |