Re: How to construct all possible orderings

• To: mathgroup at smc.vnet.net
• Subject: [mg15662] Re: How to construct all possible orderings
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Sat, 30 Jan 1999 04:28:55 -0500 (EST)
• References: <78patb\$ctc@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Carlos Carreto wrote in message <78patb\$ctc at smc.vnet.net>...
>Hello,
>
>I am trying to construct all possible orderings  of  for example 3
>elements, where each element can be A, B or C.
>
>The result will be something like this: AAA
>AAB
>AAC
>ABA
>. . .
>CCC
>
>How can I do this?
>
>Thank you.
>
>-:- Carlos
>
>
>

<<DiscreteMath`Combinatorica`

Preserving order

KSubsets[{A,A,A,B,B,B,C,C,C},3]//Union

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

Not preserving order

Join@@(Permutations/@%)

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

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

---------------------
Allan Hayes
Mathematica Training and Consulting
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

```

• Prev by Date: Re: How to construct all possible orderings
• Next by Date: Re: BesselK
• Previous by thread: Re: How to construct all possible orderings
• Next by thread: Re: How to construct all possible orderings