Skip to content

LehmerCodes ​

The Lehmer code of every permutation of {1,…,n}\{1, …, n\} — inversion tables (a0,…,an−1)(a_0, …, a_{n-1}) with 0≤ai≤n−1−i0 \le a_i \le n-1-i.

LehmerCodes(n)the Lehmer code of every permutation of {1,…,n}\{1, …, n\} — inversion tables (a0,…,an−1)(a_0, …, a_{n-1}) with 0≤ai≤n−1−i0 \le a_i \le n-1-i
Typed signatures
TypePackageApplies
(integer<0..>) -> indexed_collection<permutation_inversion>combinatoricsalways

Domain: Collections

Details
  • Count is n!n! (A000142); order-isomorphic to SymmetricGroup via the Lehmer code bijection.
  • Each element is the code itself, not the permutation it decodes to.

Definition

Epsil, as the implementation runs it.

count(_n)

_n!

unrank(_n, _r)

Map(
     Function((_r - _r % (_n - j)!) / (_n - j)! % (_n - j + 1), j),
     Range(1, _n, 1),
   )

rank(_n, _x)

Fold(Function(lr * (_n - lj + 1) + _x[lj], lr, lj), 0, Range(1, _n, 1))

valid(_n, _x)

Fold(
      Function(ok_lj && 0 <= _x[lj] && _x[lj] <= _n - lj, ok_lj, lj),
      True,
      Range(1, _n, 1),
    ) if Length(_x) == _n else False

Maps

Into and out of PermutationInversion, called as CombinatorialMap(x, "Name"). Properties are the laws we state and what FindStat records.

To PermutationInversion

  • ToLehmerCodePermutation → PermutationInversionEntry i counts the later entries smaller than p(i).

Enumeration

Examples

1 more kept as data, checked against the oracles
Basic #

Count(LehmerCodes(4))=24Count(LehmerCodes(4)) = 24

live ↗
InCount(LehmerCodes(4))\mathrm{Count}(\mathrm{LehmerCodes}(4))Out2424

The first element in enumeration order

live ↗
InLehmerCodes(4)[1]\mathrm{LehmerCodes}(4)[1]OutPermutationInversion⁡([0,0,0,0]){\operatorname{PermutationInversion}}([0, 0, 0, 0])
About
Examples3
CrosswalkWikipediaWikidataOEISSageMath

See also: SymmetricGroup, SubexcedantSeqs, Inversions