在Python中使用SymPy Partition.RGS_unrank()。
Partition.RGS_unrank(rank, n) 。RGS_unrank()是一个sympy Python库函数,它给出了大小为n的超集的无等级限制增长字符串(字符串,其中a[i]是元素i出现的块)。
限制性增长字符串–字符串中的每个字符,a i导致相应元素所属的块(B i)。
语法 : sympy.combinatorics.partitions.Partition.RGS_unrank()
返回:大小为n的超集的n级限制增长。
代码 #1 : RGS_unrank() 示例
# Python code explaining
# SymPy.RGS_unrank()
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.partitions import RGS_unrank
# Using from sympy.combinatorics.partitions.Partition.RGS_unrank() method
rank = 10
n = 5
p = RGS_unrank(rank, n)
print ("unranked restricted growth string for super size 10 : \n", p)
输出 :
unranked restricted growth string for super size 10 :
[0, 0, 1, 1, 2]
代码 #2 :RGS_unrank() 示例
# Python code explaining
# SymPy.RGS_unrank()
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.partitions import RGS_unrank
# Using from sympy.combinatorics.partitions.Partition.RGS_unrank() method
p = RGS_unrank(100, 10)
print ("unranked restricted growth string for super size 10 : \n", p)
输出 :
unranked restricted growth string for super size 10 :
[0, 0, 0, 0, 0, 1, 1, 1, 0, 1]