Skip to content

ToLehmerCode from Permutation ​

Entry i counts the later entries smaller than p(i).

Permutation → PermutationInversion

Its total is the inversion count, which is the Lehmer code's whole point.

Called as CombinatorialMap(x, "ToLehmerCode"). The head's page has its examples.