Re: String Permutation

Gene <gene.ressler@xxxxxxxxx> writes:

On Jun 6, 1:02 pm, "Stuart" <stu...@xxx> wrote:
"Richard Heathfield" <r...@xxxxxxxxxxxxxxx> wrote in message


That appears to me to be a reasonable question. Here's another - can we
establish K for a given permutation? That is, without our crib list
(above), and given a given permutation, can we calculate what value
that permutation would have occupied in our list?
The answer to both parts is yes!

As a more interesting example consider BDAC;
=> [1][3][0][2]

1*3! => 6, [2][0][1], value = 6
2*2! => 4, [0][1], value = 10
0*1! => 0, [0], value = 10

So BDAC is at position 10 in the ordered permutations of ABCD (if we start
counting at 0).
For fun, think about going the other way: computing a map that takes
every permutation of <0,1,...N-1> to a unique integer in [0..(N-1)!] .

You missed the part where Stuart did that!


Relevant Pages

  • Re: permutations
    ... snip ... ... Yours is slightly less general that Stefan Ram's. ... how his 'main' had a loop that iterates over permutations? ... code chose to print the permutation, ...
  • Re: Permutations Algorithm
    ... >> What algorithm can be used to implement a function that takes in input ... >> an interger n and gives in output all the permutation of n elements of a ...
  • Re: A Question of Permutations of Vectors of Bits
    ... Simon G Best wrote: ... Calling such a 'permutation' is very much more than not ...
  • Re: Superstitious learning in Computer Architecture
    ... Herman Rubin wrote: ... are some permutation of X, Y, and Z (I have not seen Z in ... a high-level language. ...
  • Re: Ohio Pick 4 Lottery
    ... Ohio Pick 4 for Wednesday, February 22, 2006: ... The first 500 selections, however, had some permutation ...