lehmer_code
Convert between permutations and Lehmer codes, and compute lexicographic rank or unrank permutations to support combinatorial indexing and ordering.
Instructions
Convert between permutations and Lehmer codes, compute permutation rank and unrank.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | Permutation size for unranking (use with rank) | |
| rank | No | Lexicographic rank to decode (use with n) | |
| permutation | No | Permutation of [0..n-1] to encode |