MathGroup Archive 2004

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

Search the Archive

Re: Playing with numbers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50161] Re: [mg50135] Playing with numbers
  • From: DrBob <drbob at bigfoot.com>
  • Date: Wed, 18 Aug 2004 01:20:13 -0400 (EDT)
  • References: <200408170901.FAA09893@smc.vnet.net>
  • Reply-to: drbob at bigfoot.com
  • Sender: owner-wri-mathgroup at wolfram.com

This stops with the first solution found:

Clear[test]
test[{a_, b_, c_, d_, e_, f_,
     g_, h_, i_}] :=
   If[h - f == i &&
     f*g == c && e/b == f &&
     a + b == h && c - d == a,
    Throw[{a, b, c, d, e, f,
      g, h, i}]]
Timing@Catch[test /@ Permutations@Range@9]
{2.5*Second, {5, 4, 6, 1, 8, 2, 3, 9, 7}}

and this returns ALL solutions:

Clear@test
test[{a_, b_, c_, d_, e_, f_, g_, h_,
     i_}] := If[h - f == i && f*g == c &&
     e/b == f && a + b == h &&
     c - d == a, Sow[{a, b, c, d, e, f,
      g, h, i}]]

Timing@Last@Reap[test/@Permutations@Range@9]

{4.781 Second,{{{5,4,6,1,8,2,3,9,7}}}}

Bobby

On Tue, 17 Aug 2004 05:01:03 -0400 (EDT), Thomas Manz <thomasmanz at web.de> wrote:

> Hello!
>
> Everyone of you knows number riddles! Here´s an example:
> you have five equations:
> (1) H - F = I
> (2) F x G = C
> (3) E / B = F
> (4) A + B = H
> (5) C - D = A
> every variable from A to I stands for a number from 1 to 9, where each number appears only once (no two variables can have the same value)!!
>
> Solving this problem with a piece of paper and your brain should take not more than 10 minutes.
> (I tried it, and also found that 5-4-6-1-8-2-3-9-7 (A-I) is the ONLY solution!)
>
> But how can I solve it with Mathematica??
>
> best regards
> Thomas
>
>
>
>



-- 
DrBob at bigfoot.com
www.eclecticdreams.net


  • Prev by Date: Re: Re: Smallest enclosing circle
  • Next by Date: Re: Adaptive FunctionInterpolation[] ?
  • Previous by thread: Playing with numbers
  • Next by thread: Re: Playing with numbers