Re: Arrangements
- To: mathgroup at smc.vnet.net
- Subject: [mg108937] Re: Arrangements
- From: Ray Koopman <koopman at sfu.ca>
- Date: Wed, 7 Apr 2010 07:26:25 -0400 (EDT)
- References: <hpf5iu$orh$1@smc.vnet.net>
On Apr 6, 4:23 am, John <j... at lehigh.edu> wrote: > Google 6, Windows-Xp > > The number of different arrangements of sixteen symbols -- eight > letters A and eight letters B -- is Binomial[16,8]=12870. Is there a > command that will generate all 12870 arrangements one at a time > without duplication? Any order is acceptable. > > I used RandomSample[Range[16]] to select a random permutation of > sixteen different symbols. Assigning the letter A to the first eight > numbers in the random permutation and the letter B to the last eight > letters in the permutation created a randomly selected arrangement. > Awkward, but it works because Binomial[2n,n](n!)(n!)=(2n)!). > > John If you really do want them one at at time instead of all at once then NextKSubset will give you the positions of the A's (or B's). Here's a toy example for 2 A's and 2 B's. s = {1,2} s = NextKSubset[{1,2,3,4}, s] s = NextKSubset[{1,2,3,4}, s] s = NextKSubset[{1,2,3,4}, s] s = NextKSubset[{1,2,3,4}, s] s = NextKSubset[{1,2,3,4}, s] s = NextKSubset[{1,2,3,4}, s] {1,2} {1,3} {1,4} {2,3} {2,4} {3,4} {1,2}