Re: How to construct all possible orderings

• To: mathgroup at smc.vnet.net
• Subject: [mg15618] Re: [mg15588] How to construct all possible orderings
• From: Daniel Lichtblau <danl>
• Date: Sat, 30 Jan 1999 04:28:21 -0500 (EST)
• References: <199901280923.EAA13076@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Carlos Carreto wrote:
>
> 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

chooseWithReplacement[set_List, n_Integer] := With[
{m=Length[set]},
Table[IntegerDigits[j,m,n], {j,0,m^n-1}] /.

In[14]:= chooseWithReplacement[{aa,bb,cc}, 4] // InputForm
Out[14]//InputForm=
{{aa, aa, aa, aa}, {aa, aa, aa, bb}, {aa, aa, aa, cc}, {aa, aa, bb, aa},
{aa, aa, bb, bb}, {aa, aa, bb, cc}, {aa, aa, cc, aa}, {aa, aa, cc, bb},
{aa, aa, cc, cc}, {aa, bb, aa, aa}, {aa, bb, aa, bb}, {aa, bb, aa, cc},
{aa, bb, bb, aa}, {aa, bb, bb, bb}, {aa, bb, bb, cc}, {aa, bb, cc, aa},
{aa, bb, cc, bb}, {aa, bb, cc, cc}, {aa, cc, aa, aa}, {aa, cc, aa, bb},
{aa, cc, aa, cc}, {aa, cc, bb, aa}, {aa, cc, bb, bb}, {aa, cc, bb, cc},
{aa, cc, cc, aa}, {aa, cc, cc, bb}, {aa, cc, cc, cc}, {bb, aa, aa, aa},
{bb, aa, aa, bb}, {bb, aa, aa, cc}, {bb, aa, bb, aa}, {bb, aa, bb, bb},
{bb, aa, bb, cc}, {bb, aa, cc, aa}, {bb, aa, cc, bb}, {bb, aa, cc, cc},
{bb, bb, aa, aa}, {bb, bb, aa, bb}, {bb, bb, aa, cc}, {bb, bb, bb, aa},
{bb, bb, bb, bb}, {bb, bb, bb, cc}, {bb, bb, cc, aa}, {bb, bb, cc, bb},
{bb, bb, cc, cc}, {bb, cc, aa, aa}, {bb, cc, aa, bb}, {bb, cc, aa, cc},
{bb, cc, bb, aa}, {bb, cc, bb, bb}, {bb, cc, bb, cc}, {bb, cc, cc, aa},
{bb, cc, cc, bb}, {bb, cc, cc, cc}, {cc, aa, aa, aa}, {cc, aa, aa, bb},
{cc, aa, aa, cc}, {cc, aa, bb, aa}, {cc, aa, bb, bb}, {cc, aa, bb, cc},
{cc, aa, cc, aa}, {cc, aa, cc, bb}, {cc, aa, cc, cc}, {cc, bb, aa, aa},
{cc, bb, aa, bb}, {cc, bb, aa, cc}, {cc, bb, bb, aa}, {cc, bb, bb, bb},
{cc, bb, bb, cc}, {cc, bb, cc, aa}, {cc, bb, cc, bb}, {cc, bb, cc, cc},
{cc, cc, aa, aa}, {cc, cc, aa, bb}, {cc, cc, aa, cc}, {cc, cc, bb, aa},
{cc, cc, bb, bb}, {cc, cc, bb, cc}, {cc, cc, cc, aa}, {cc, cc, cc, bb},
{cc, cc, cc, cc}}

Daniel Lichtblau
Wolfram Research

```

• Prev by Date: Re: question [using result of DSolve]
• Next by Date: Re: question
• Previous by thread: Re: How to construct all possible orderings
• Next by thread: Re: How to construct all possible orderings