       Re: Arrangements

• To: mathgroup at smc.vnet.net
• Subject: [mg108911] Re: Arrangements
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Tue, 6 Apr 2010 08:43:46 -0400 (EDT)

```lst = Table[{"A", "B"}, {8}] // Flatten

{A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B}

p = Permutations[lst];

Length[p] == Binomial[16, 8]

True

There are no duplicates

Length[Union[p]] == Length[p]

True

p[[RandomInteger[{1, Length[p]}]]]

{B,A,B,A,B,A,B,A,B,A,A,B,A,B,B,A}

Bob Hanlon

---- John <jwa0 at lehigh.edu> wrote:

=============

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] 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

```

• Prev by Date: Re: Integration error
• Next by Date: Simplifying multiple expressions
• Previous by thread: Re: Arrangements
• Next by thread: Re: Arrangements