Open In App

SymPy | Partition.RGS_unrank() in Python

Improve
Improve
Like Article
Like
Save
Share
Report

Partition.RGS_unrank(rank, n) : RGS_unrank() is a sympy Python library function that gives the unranked restricted growth strings (string where a[i] is the block in which element i occurs) 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_unrank()

Return : nranked restricted growth for a superset of size n.

Code #1 : RGS_unrank() Example




# 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)


Output :

unranked restricted growth string for super size 10 :
[0, 0, 1, 1, 2]

Code #2 : RGS_unrank() Example




# 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)


Output :

unranked restricted growth string for super size 10 :
[0, 0, 0, 0, 0, 1, 1, 1, 0, 1]


Last Updated : 26 Aug, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads