I would like to get the Nth element of a permutation list without creating all of the permutations
If I execute perm = permutations(range(3))
I get:
(0, 1, 2) (0, 2, 1) (1, 0, 2) (1, 2, 0) (2, 0, 1) (2, 1, 0)
And I can get the 4th element by doing perm[3]
that is (1, 2, 0)
The problem comes when I want to get the 12843175th element of permutations(range(12))
or higher because my computer causes memory error
Is there a more optimal way to obtain this value?