Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- k-th permutation of n elements [a b c d ... ]
- idx1 = int(k/(n-1)!)
- k = k % (n-1)!
- idx2 = int(k/(n-2)!)
- k = k % (n-1)!
- idx3 = int(k/(n-3)!)
- k = k % (n-1)!
- ...
- idxn = ...
- Then extract the element idx1 from the array of elements (it results in a new array)
- From the new array pick the idx2 element
- And so on
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement