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

• To: mathgroup at smc.vnet.net
• Subject: [mg71362] Re: Arithmetic Puzzle (so simple it's hard)
• From: "astanoff" <astanoff at gmail.com>
• Date: Wed, 15 Nov 2006 06:45:50 -0500 (EST)
• References: <ejc4pv\$6nf\$1@smc.vnet.net>

```
On 14 nov, 11:12, Bruce Colletti <vze26... at verizon.net> wrote:
> 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

Hi,

This my way to do it by brute force :

In[1]:=n=9;
di={b,u,t,a,s,k,f,e};
cond=And@@(Outer[#1 != #2&,di,di]//Flatten//Union//Rest);
Do[If[cond &&
FromDigits[{b,u,t}]*FromDigits[{a,s,k}] ==
FromDigits[{f,e,a,s,t}],
Print[{b,u,t},{a,s,k},{f,e,a,s,t}];
Break[]],

{b,1,n},{u,0,n},{t,0,n},{a,1,n},{k,0,n},{s,0,n},{f,1,n},{e,0,n}]//Timing

>From In[1]:={1,6,0} {2,8,3} {4,5,2,8,0}

Out[21]={54.937 Second,Null}

In[22]:=160*283==45280

Out[22]=True

V.Astanoff

( hoping someone will post something more elegant ! )

```

• Prev by Date: Re: Arithmetic Puzzle (so simple it's hard)
• Next by Date: Re: List difference using patterns and substitutions.
• Previous by thread: Re: Arithmetic Puzzle (so simple it's hard)
• Next by thread: Re: Arithmetic Puzzle (so simple it's hard)