github.com/deltam/perm (go): Package perm provides a permutation generator based on group theory.  With this algorithm, all permutations can be done with only swap(0,1,2,3 -> 1,0,2,3) and rotation(0,1,2,3 -> 1,2,3,0). Implementations are OpSwap and OpRotate respectively. The permutation order starts with (n-2,n-1,n-3,...,2,1,0) and ends with (n-3,n-2,n-1,...,2,1,0), not lexical.  The generated permutations belong to either Small Cycle or Large Cycle. The generated permutations start with small cycle and end with large cycle.  Small cycle is start from permutation initialized by Init(), end at reverse order(n-1,n-2,...,1,0). If applied swap to small cycle end, move to start. If applied rotate to small cycle end, move to permutation contained of large cycle.  This algorithm is based on following paper[1] and its commentary article[2] below.  [^1] Hamiltonicity of the Cayley Digraph on the Symmetric Group Generated by σ = (1 2 ... n) and τ = (1 2) https://arxiv.org/abs/1307.2549  [^2] 2つの操作のみで全順列を列挙する：対称群のグラフ上のハミルトン路にもとづく順列生成の紹介と実装 : サルノオボエガキ https://deltam.blogspot.com/2019/12/permutationgenerator.html
Keywords: golang|permutation-generator