MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Why are permutations duplicated with LexicographicPermutations? How to avoid this?


When I enter

LexicographicPermutations[{a, b, 0, 0}]

the result is following:
{{a, b, 0, 0}, {a, b, 0, 0}, {a, 0, b, 0}, {a, 0, 0, b}, {
   a, 0, b, 0}, {a, 0, 0, b}, {b, a, 0, 0}, {b, a, 0, 0}, {
   b, 0, a, 0}, {b, 0, 0, a}, {b, 0, a, 0}, {b, 0, 0, a}, {
   0, a, b, 0}, {0, a, 0, b}, {0, b, a, 0}, {0, b, 0, a}, {
   0, 0, a, b}, {0, 0, b, a}, {0, a, b, 0}, {0, a, 0, b}, {
   0, b, a, 0}, {0, b, 0, a}, {0, 0, a, b}, {0, 0, b, a}}


Why does the result repeat duplicate cases?
In my case I must perform exact functionality of 
LexicographicPermutations[{0,C,D,0,G,H,J,0,0,P,0,0,T,V,0,X,Y,0,0,4,0,7,8,0}]; 
since there are lots of duplicates I'm trying to implement this in C++ 
for maximum speed.

Can this be avoided in Mathematica itself, and how?


  • Prev by Date: Re: expression formatting inside tables
  • Next by Date: Re: Labels on graphs
  • Previous by thread: Re: Re: Re: Simplify and Abs
  • Next by thread: Re: Why are permutations duplicated with LexicographicPermutations? How to avoid this?