MathGroup Archive 2004

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

Search the Archive

Re:Playing with numbers

  • To: mathgroup at
  • Subject: [mg50223] Re:[mg50135] Playing with numbers
  • From: "Fred Simons" <f.h.simons at>
  • Date: Sat, 21 Aug 2004 03:04:29 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

The question is to solve with Mathematica the set of equations
(1) H - F = I
(2) F x G = C
(3) E / B = F
(4) A + B = H
(5) C - D = A
where every variable from A to I stands for a number from 1 to 9 and each
number appears only once.

Here is a solution where Mathematica does the computations that we otherwise
had to do by hand.

Since the symbols represent different integers between 1 and 9, we conclude
from the equations i+f=h, a+b=h that h has to be at least 5. From the
equations c=f*g, e=f*b we conclude that f is between 2 and 4, that g is at
least 2, that e is at least 2, that c is at least 6 and that e is at least

Given values for f, h, c and e, we can compute the other variables. The
result has to be a permutation of the numbers 1, ..., 9.

In[21]:= solution = {a, b, c, d, e, f, g, h, i} /.
Solve[{h - f == i, f*g == c, e/b == f,
a + b == h, c - d == a}, {a, b, d, g, i}][[1]]

{-((e - f*h)/f), e/f, c, c + e/f - h, e, f, c/f, h, -f + h}

Timing[Do[If[Length[Union[solution]] == 9,
Print[solution]], {f, 2, 4},
{c, Ceiling[5/f]*f, 9, f}, {e, Ceiling[5/f]*f, 9, f}, {h, 5, 9}]]

From In[23]:=

{0. Second,Null}

So indeed there is only one solution.

Fred Simons
Eindhoven University of Technology

  • Prev by Date: Re: Beware of adding 0.0
  • Next by Date: Re: Comparison of Mathematica on Various Computers
  • Previous by thread: Re: Playing with numbers
  • Next by thread: Re: Re:Playing with numbers