Python中的SymPy Permutation.next_lex()
Permutation.next_lex() : next_lex()是一个Sympy Python库函数,用于返回按词典顺序排列的下一个排列组合,如果自己是按词典顺序排列的最后一个排列组合,则返回None。
语法 : sympy.combinatorics.permutations.Permutation.next_lex()
返回:按词典顺序排列的下一个排列组合
代码 #1 : next_lex() 示例
输出 :
Permutation a – next_lex form : (0 2 1 3)
Permutation b – next_lex form : (5)(0 1 4 3 2)
代码 #2 : next_lex() 例子 – 二维排布
输出 :
Permutation a – next_lex form : (6)(0 3 5)(1 2 4)