Re: Enumerating Permutations
- To: mathgroup at smc.vnet.net
- Subject: [mg20055] Re: [mg20006] Enumerating Permutations
- From: BobHanlon at aol.com
- Date: Wed, 29 Sep 1999 03:33:20 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Vic, I believe what you are looking for is RankPermutation Needs["DiscreteMath`Combinatorica`"] perms = Permutations[Range[4]]; ?RankPermutation "RankPermutation[p] gives the rank of permutation p in lexicographic order." RankPermutation[{3, 2, 1, 4}] 14 RankPermutation /@ perms {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, \ 21, 22, 23} Bob Hanlon In a message dated 9/25/1999 4:59:09 AM, fanberg at email.msn.com writes: >I am looking for an algorithm for determining the Nth permutation (P) of >a >group T. I don't really care the ordering of the permutations within T, >as >long as all the permutations of P are members of T exactly once. (Each >element of the permutation P is unique.) > >Actually, each of the permutations are only 7 digits long and I could list >all 5040 permutations in a file about 35K, but I was hoping for something >a >little cleaner, in case I change to 8 or 9 digits long later. > >Does anyone know of such an algorithm? >