MathGroup Archive 1995

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

Search the Archive

Re: Puzzle


>Here's a nice puzzle.  Find the four numbers in the following sequence
>which total 100:  {6, 44, 30, 15, 24, 12, 33, 23, 18}.  It would seem that
>there might be a nice way to do this with Mathematica.  Any takers?
>
>Will Self
>Billings, Montana

The easiest way I've found is:

In[6]:=
{6, 44, 30, 15, 24, 12, 33, 23, 18}/.
{a___,b_,c___,d_,e___,f_,g___,h_,i___} /; b + d + f + h == 100 -> {b,d,f,h}
Out[6]=
{44, 15, 23, 18}

Cheers,
Bruce Carpenter




  • Prev by Date: Re: Puzzle
  • Next by Date: Kernel function to create Windows Metafile?
  • Previous by thread: Re: Puzzle
  • Next by thread: Re: Puzzle