Python中的SymPy Partition.next_lex()

Python中的SymPy Partition.next_lex()

Partition.next_lex() : next_lex()是一个sympy Python库函数,它返回下一个整数分区,n为lexicographical顺序。如果分区是[1,…,1],这个排序就会环绕[n]。

**语法 : ** sympy.combinatorics.partitions.Partition.next_lex()

返回 :下一个整数分区,n为lexicographical顺序

代码 #1 : next_lex() 示例

Python3 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())

Python

输出 :

p : [312, 121, 14, 5] Next Integer : [312, 121, 15, 1, 1, 1, 1]

代码#2:next_lex()示例

Python3 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([1, 312, 121, 14, 
                      34, 56, 32])

print('p : ', p)
print('\nNext Integer : ', p.next_lex())

Python

输出 :

p : [312, 121, 56, 34, 32, 14, 1] Next Integer : [312, 121, 56, 34, 32, 15]

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

登录

注册