SymPy | Python中的 Partition.next_lex()
Partition.next_lex() :next_lex()是一个 sympy Python库函数,它按字典顺序返回下一个整数分区 n。如果分区为 [1, ..., 1],则此排序环绕 [n]。
Syntax : sympy.combinatorics.partitions.Partition.next_lex() Return : next integer partition, n in lexicographical order
代码 #1:next_lex() 示例
蟒蛇3 1=1
# Python code explaining
# SymPy.next_lex()
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.partitions import IntegerPartition
# Using from sympy.combinatorics.partitions.Partition.next_lex() method
p = IntegerPartition([312, 121, 14, 5])
print('p : ', p)
print('\nNext Integer : ', p.next_lex())