MathGroup Archive 1995

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

Search the Archive

Re: Puzzle

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2294] Re: Puzzle
  • From: bshoels at rs1.tcs.tulane.edu (Brett Shoelson)
  • Date: Mon, 23 Oct 1995 12:41:13 -0400
  • Organization: Tulane University

Will Self (wself at viking.emcmt.edu) wrote:
: 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

There are 126 possible 4-number combinations from the set of 9
numbers... (9!/(4! * (9-4)!). How to generate these sets is another
matter entirely. Unless I am missing something, there seems to be no
Combinations[list,n] function which gives all combinations of length n
from list. I could write a recursive Table command to generate them, but
it would not be a very elegant approach.

Once the set of all 4-number sets is generated, the problem becomes easy
in Mma. Here is one approach, which, in my example, selects the subsets
of Example which sum to 17:

Example = {{6,7,4},{3,5,6},{1,2,7},{9,3,5}};

sums = Table[Apply[Plus,Example[[i]]],{i,Length[Example]}];

positions = Flatten[Position[MySums,17]];

Table[Example[[positions[[i]]]],{i,1,Length[positions]}]

{{6, 7, 4}, {9, 3, 5}}


So, the problem is ESSENTIALLY solved. Now, if anyone can tell me how to
(easily) generate the set of 4-number combinations (subsets) of the
original 9-member set, I would be very grateful.

Brett Shoelson
bshoels at rs6000.tcs.tulane.edu



  • Prev by Date: Help with factoring out an exponential
  • Next by Date: Restrictions
  • Previous by thread: Re: Puzzle
  • Next by thread: Re: Puzzle