📜  SymPy | Python中的 Partition.prev_lex()

📅  最后修改于: 2022-05-13 01:55:42.821000             🧑  作者: Mango

SymPy | Python中的 Partition.prev_lex()

Partition.prev_lex() :prev_lex()是一个 sympy Python库函数,它返回前一个整数分区,按字典顺序排列 n。如果分区为 [1, ..., 1],则此排序环绕 [n]。

代码 #1:prev_lex() 示例

蟒蛇3 1=1

]

# Python code explaining
# SymPy.prev_lex()

# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.partitions import IntegerPartition

# Using from sympy.combinatorics.partitions.Partition.prev_lex() method 
p = IntegerPartition([312, 121, 14, 5])

print('p : ', p)
print('\nPrevious Integer : ', p.prev_lex())