

Permutations Mafipulations Pt. 1 | Code Exposure - sadanjon
http://sadanjon.wordpress.com/2011/07/16/permutations-mafipulations-pt-1/

======
andrewcooke
[spoiler, i think?] i'm a bit confused - perhaps this is going to be the part
2, but it's not really that complicated (i don't mean to be rude - just that
the article makes things so clear the rest is obvious). for a permutation you
are making a choice from n, then n-1, then... if you number/index all the
permutations then you can reconstruct the permutation for any particular
index. to get permutation N, for example, you find the first choice by finding
N mod (n-1)(n-2)...1, the second by doing the same to the remainder (but with
(n-2)(n-3)...), etc. from that you can construct the permutation (selecting
the first choice value from the set, then the next, etc).

think of it like numbering the nodes in a decision tree. at the root you have
n sub-trees, each with (n-1)! nodes. rinse + repeat.

~~~
sadanjon
Thanks for reading, and yeah! You got the idea right. Didn't mean to make it
sound complicated. It's just something I found myself messing around with a
couple of days ago.

~~~
andrewcooke
it was interesting - as i said, the article helped (i don't think i'd have
thought of the answer before reading it).

[huh. so i was the only person who voted this up? for what it's worth, hn is
going downhill fast. this kind of article would have been more popular in the
last...]

ps this would be related to numbers of variable base, i think - that might be
an interesting connection to follow (although google isn't turning up much...)

~~~
andrewcooke
[http://en.wikipedia.org/wiki/Non-
standard_positional_numeral...](http://en.wikipedia.org/wiki/Non-
standard_positional_numeral_systems)

<http://en.wikipedia.org/wiki/Factorial_number_system> (which makes your
indexing as simple as reading the digits from the number, i think)

yes - here it is -
[http://en.wikipedia.org/wiki/Factorial_number_system#Permuta...](http://en.wikipedia.org/wiki/Factorial_number_system#Permutations)
:o)

~~~
sadanjon
So great man! I'm so happy for this, although the second part is already
written I'm definitely going to mention this. This is almost the same solution
as I've come up with there! Thanks!

