Re: Combinations
- To: mathgroup at smc.vnet.net
- Subject: [mg61716] Re: [mg61677] Combinations
- From: Sseziwa Mukasa <mukasa at jeol.com>
- Date: Thu, 27 Oct 2005 05:01:43 -0400 (EDT)
- References: <200510260501.BAA18717@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On Oct 26, 2005, at 1:01 AM, xxxxyz at abv.bg wrote: > Hi, > > Is there any way to generate combinations per turn in a cycle? I mean > first generate one combination, do something, generate next, do the > same thing ... > > Thanks. The combinations are called KSubsets in Mathematica, the Combinatorica package contains the necessary routines. The first KSubset in lexicographic order is simply Range[k], you can use NextKSubset to see the others for example: <<DiscreteMath`Combinatorica` Block[{subset = Range[3]},Prepend[Table[subset = NextKSubset[Range [5], subset], {4}], Range[3]]] will return the first 5 subsets of length 3 of {1,2,3,4,5} in lexicographic order. There are functions to get the KSubsets in other orders in Combinatorica, I suggest you read the Help Browser information or read "Computational Discrete Mathematics: Combinatorics and Graph Theory with Mathematica" by Steven Skiena and Sriram Pemmaraju for more information on the package. Regards, Ssezi
- Follow-Ups:
- Re: Re: Combinations
- From: "Carl K. Woll" <carlw@wolfram.com>
- Re: Re: Combinations
- References:
- Combinations
- From: "xxxxyz@abv.bg" <xxxxyz@abv.bg>
- Combinations