id-permutations
Blazing fast algorithms for generating a list of permutations for a given id, or the id from its corresponding permutation.
Example
const N_POSITIONS = 10;const getPermutationsFromId getIdFromPermutations = N_POSITIONS; ; // => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; // => [1, 0, 2, 3, 4, 5, 6, 7, 8, 9]; // => [2, 0, 1, 3, 4, 5, 6, 7, 8, 9]; // => [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] ; // => 0; // => 1; // => 2; // => 3628799