Atom - Œ? - Permutation for Index

Characters: Π, ?

Tags: miscellaneous , array , combinatorics , vectorize

Arity: monadic

This atom is monadic, which means it takes one argument.


Find the shortest permutation of [1, 2, ..., N] for some N that yields z when passed through Œ¿ (Permutation Index).


Right inverse of Œ¿. The permutation's length will be the minimum N such that z ≤ N!. Note that not every permutation is a possible output; for example, [1, 3, 2] cannot be output because its permutation index is 2, which can be represented by [2, 1] instead.