The Lehmer code and the factorial number system for ranking and unranking permutations, in pure Python with zero dependencies: encode a permutation to its inversion vector and back, convert integers ...