I'd like to write a JavaScript program that arranges a set of 36 numbers in all possible permutations (10 permutations per second). There are 36 factorial ways to arrange these numbers.
I know that my program won't end until the end of the earth :) (that's exactly what I want to show).
It starts with the following sequence:
- permutation: 0,1,2,3,4,5,6,...,32,33,34,35
- permutation: 0,1,2,3,4,5,6,...,32,33,35,34
- permutation: 0,1,2,3,4,5,6,...,32,34,33,35
..... (A LOT more permutations here)....
Is there a way to calculate the 5'595'000'000th (time in deciseconds since 01.01.2000) permutation without calculating all the previous ones? Calculate the previous ones would literally take forever!
Also, if I know the 5'595'000'000th permutation I need a way to calculate the next one.
All permutation algorithms I found calculate all permutations at once. Which is not an option with that many permutations.
Is this even possible or am I doomed?