Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: combinatoric card problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25854] Re: combinatoric card problem
  • From: Will Self <wself at msubillings.edu>
  • Date: Wed, 1 Nov 2000 01:25:39 -0500 (EST)
  • References: <8tdrsn$61d@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <8tdrsn$61d at smc.vnet.net>,
  "pw" <pewei at nospam.algonet.se> 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

Are parentheses allowed in the Chinese game?  I would think if it's a
folk game, the operations would have to be applied in order, like the
old-fashioned hand calculators.  Anyway, assuming you do allow
parentheses, you can solve this in Mathematica by just trying every
possibility.  I wouldn't know of any other way.

---------------------------------------------------------------

(*  Define a reverse division and subtraction: *)
divR[x_, y_] := Divide[y, x]
subR[x_, y_] := Subtract[y, x]

(* There are now six operations but we only use three in any particular
try. *)

(* Define the function f to show how to apply the operations to
numbers: *)

f[operations[h1_, h2_, h3_], numbers[n1_, n2_, n3_, n4_]] :=
  h1[n1, h2[n2, h3[n3, n4]]]

(* Now just try every possible combination.  Don't use a slow computer.
*)

cardSolution[{a_, b_, c_, d_}] :=
Select[Flatten[Outer[use, Flatten[Outer[operations,
  Sequence @@ Table[{Plus, Subtract, subR, Times, Divide, divR},
{3}]]],
 numbers @@ # &  /@ Permutations[{a, b, c, d}]]], (# /. use -> f) == 24
&]


(* Try it: *)
cardSolution[{6, 7, 8, 12}] // ColumnForm

----------------------------------------------------------------

Will Self


Sent via Deja.com http://www.deja.com/
Before you buy.


  • Prev by Date: Re: combinatoric card problem
  • Next by Date: Re: combinatoric card game
  • Previous by thread: Re: combinatoric card problem
  • Next by thread: Re: combinatoric card problem