I ran across this question this morning.
Basically that question is about data which has to create permutations for 6 values; each one ranging from 1 to 38.
So, first permutation would be
1 1 1 1 1 1 [ permutation 1 ]
1 1 1 1 1 2 [ permutation 2 ]
1 1 1 1 1 3... [ permutation 3 ]
to end much later with
38 38 38 38 38 38 [ permutation 38^^6 ]
The output is simply created by 6 nested loops, each counting from 1 to 38; and within the inner-most loop, you print the 6 loop counters.
Now I am wondering about the math behind that; and out of curiosity: what would be the "function" that
- computes the "permutation index", given a any permutation 1 2 3 4 5 6
- Probably more interesting: that takes an "index", such as 102382; and tells me the corresponding permutation output
Any idea anybody?