MathGroup Archive 2011

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

Search the Archive

Re: Combinations and Counting

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118924] Re: Combinations and Counting
  • From: Peter Pein <petsie at dordos.net>
  • Date: Mon, 16 May 2011 03:34:21 -0400 (EDT)
  • References: <iqoc0v$m8r$1@smc.vnet.net>

Am 15.05.2011 13:05, schrieb Dean Rosenthal:
> What might be the most efficient way to write a little program that counted
> combinations in the following way:
> 
> 1 choose 1, 2 choose 1, 2 choose 2, 3 choose 1, 3 choose 2, 3 choose 3, 4
> choose 1, 4 choose 2, 4 choose 3 ... continuing the pattern ...
> 
> So that I would be able to derive each subset in that order?  Invoking
> "subsets" in the most rudimentary way *almost* gets me there, but I would
> like to see the output of this series of combinations in this special order,
> in column form, and be able to carry out my search much further.
> 
> Suggestions?
> 
> Thanks!
> 
> DR
Hi,

if I'm not completely wrong,

NestList[(Plus @@@ Partition[Flatten[{1, #, 0}], 2, 1])&, {1}, 5]

should do the list. Replace "5" by your upper bound.

Peter



  • Prev by Date: Re: Combinations and Counting
  • Next by Date: Re: Histogram omits data points
  • Previous by thread: Re: Combinations and Counting
  • Next by thread: Re: Combinations and Counting