       Re: combinatoric card problem

• To: mathgroup at smc.vnet.net
• Subject: [mg25853] Re: combinatoric card problem
• From: Alberto Ruiz <ARuiz at um.es>
• Date: Wed, 1 Nov 2000 01:25:39 -0500 (EST)
• Organization: University of Murcia, Spain
• References: <8tdrsn\$61d@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Peter, a brute force idea is to try all the permutations
of numbers and operations:

f = Plus;
f = #1 - #2 &;
f = Times;
f = #1/#2 &;
f = #2 - #1 &;
f = #2/#1 &;

p[f] = S;
p[f] = R;
p[f] = M;
p[f] = Di;
p[f] = Rc;
p[f] = Dc;  (* some symbols chosen just to show the solutions *)

pf = Take[#, 3] & /@ Permutations[Array[f, 6]];
pn = Permutations[{6, 7, 8, 12}];

g[{f1_, f2_, f3_}, {a_, b_, c_, d_}] :=
kk[f1[a, f2[b, f3[c, d]]], p[f1][a, p[f2][b, p[f3][c, d]]]]

bruteforce = Outer[g, pf, pn, 1] // Flatten;
Cases[bruteforce, kk[24, b_] -> b] // Union

{Dc[7, M[12, S[6, 8]]],
Dc[7, M[12, S[8, 6]]],
M[12, Dc[7, S[6, 8]]],
M[12, Dc[7, S[8, 6]]]}

Of course this can be improved in many ways...

Alberto

pw wrote:
>
> In China they often play this card game:
> put four card on a table and try, as fast as possible, to arrive to the
> result 24 using only addtion subtraction multiplication and division.
>
> ex. the cards: { hearts_6 ,hearts_7 ,clove_8 ,spades_king } gives the
> numbers:
>
> {6,7,8,12}
>
> and 12*(6+8)/7=24
>
> Is there some way to do determine how to do this with mathematica, or maybe
> there is some way to determine if a certain quadruple can make the required
> result?
>
> Peter W

```

• Prev by Date: Re: About Parallel Computing
• Next by Date: Re: Vertical Tangents