SymPy | Partition.RGS_enum() in Python
Last Updated :
26 Aug, 2019
Partition.RGS_enum() : RGS_enum() is a sympy Python library function that calculates the total number of restricted growth strings (string where a[i] is the block in which element i occurs) which is possible for a superset of size n.
Restricted growth strings – string in which each character, ai results in the Block (Bi) in which the corresponding element belongs.
Syntax : sympy.combinatorics.partitions.Partition.RGS_enum()
Return : total number of restricted growth strings, possible for a superset of size n.
Code #1 : RGS_enum() Example
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.partitions import RGS_enum
p = RGS_enum( 4 )
q = RGS_enum( 9 )
print ( "no. of strings possible for size 4: " , p)
print ( "no. of strings possible for size 9: " , q)
|
Output :
no. of strings possible for size 4: 15
no. of strings possible for size 9: 203
Code #2 : RGS_enum() Example
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.partitions import RGS_enum
p = RGS_enum( 20 )
q = RGS_enum( - 1 )
print ( "no. of strings possible for size 20 " , p)
print ( "no. of strings possible for size -1: " , q)
|
Output :
no. of strings possible for size 20 51724158235372
no. of strings possible for size -1: 0
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...