Re: Help ! complex permutations
- To: mathgroup at smc.vnet.net
- Subject: [mg7030] Re: Help ! complex permutations
- From: uyurtsever at dynatec.com (Ulvi Yurtsever)
- Date: Fri, 2 May 1997 21:30:55 -0400 (EDT)
- Organization: AT&T WorldNet Services
- Sender: owner-wri-mathgroup at wolfram.com
On 29 Apr 1997 21:40:11 -0400, Robert_P at pro-bel.co.uk (Robert Perkins)
wrote:
>I need to derive an algorithm, formula, which gives all the
>possiblities, combinations, for any 'n' out of 'm' with the proviso
>that any member of 'm' can be used multiple times and the selection
>sequence is significant.
>
>Taking a trivial example if the input list 'm' is
>
> {a,b}
>
>the output list 'n' for any 2 gives
>
> {a,a},{a,b},{b,a},{b,b}
>
>For an output sequence of 3 from the same input list would give
>
> {a,a,a},{a,a,b},{a,b,b},{b,a,b},{b,b,a},{b,b,b}
You forgot {a,b,a} and {b,a,a}, I think...
>
>Life gets interesting for larger input sequences and ever larger
>output selections. How about the input list containing 10 members and
>the output list containing 20 members with the above rules applying?
>
>Can anyone point me in the right direction? A reference, clue or even
>an algorithm would be very welcome ;)
>
>TIA
>
>Robert_p
Why isn't this set of all possible combinations simply the cartesian
product mXmXmX...Xm, where the product has as many terms as the number
of elements n you want in the output?
The total number of all possible combinations is then |m|^n, and
Mathematica has a list-product function called Outer which will
compute the cartesian product set for you.
hope this is helpful