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

news:08mdnfdfWeQ8G_vbnZ2dnUVZ8qTinZ2d@xxxxxxxxx

<snip>
<snip>
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?
<snip>
The answer to both parts is yes!

<snip>
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).
<snip>
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!

--
Ben.
.



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, ...
    (comp.lang.c)
  • 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 ...
    (comp.programming)
  • Re: A Question of Permutations of Vectors of Bits
    ... Simon G Best wrote: ... Calling such a 'permutation' is very much more than not ...
    (sci.crypt)
  • 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. ...
    (comp.arch.arithmetic)
  • Re: Ohio Pick 4 Lottery
    ... Ohio Pick 4 for Wednesday, February 22, 2006: ... The first 500 selections, however, had some permutation ...
    (alt.2600)