Python | Sympy partitions.RGS_unrank() method

Python | Sympy partitions.RGS_unrank() method

In combinatorics, a restricted growth string (RGS) is a string that begins with 0 and where each successive element is no more than one greater than the maximum of all previous elements. RGS can represent partitions of a set in a specific way.

SymPy, a Python library for symbolic mathematics, provides functions related to combinatorial objects in its partitions module. Among them, the RGS_unrank() function converts a rank into its corresponding restricted growth string (RGS).

Syntax:

sympy.combinatorics.partitions.RGS_unrank(rank, size) 

Parameters:

  • rank: int
    • The rank of the RGS.
  • size: int
    • The length of the RGS to be generated.

Returns:

  • A list of integers representing the RGS.

Example:

To use the RGS_unrank() method, follow this example:

from sympy.combinatorics.partitions import RGS_unrank # Rank and size rank = 10 size = 5 # Compute the RGS rgs = RGS_unrank(rank, size) print(rgs) 

This code will convert a given rank into its corresponding restricted growth string of a specific size. Ensure you have SymPy installed in your environment to run the above code.


More Tags

docker-desktop deterministic basic-authentication streamreader qos pg r-plotly django-rest-auth putty prettier

More Programming Guides

Other Guides

More Programming Examples