Python | sympy from_rgs () method

With the sympy.combinatorics.Partition.from_rgs() method, we can get an array of subarrays by passing in an array of indices and a list of members using sympy.combinatorics. Partition.from_rgs () .

Syntax: sympy.combinatorics.Partition.from_rgs()

Return: Return the array of subarrays.

Example # 1:
In this example, we see that with sympy.combinatorics.Partition.from_rgs () we can get the array of the subarray by passing the array of indices and the list of members according to the parameters.

# import sympy and Relational

from sympy.combinatorics.partitions import Partition

from sympy import *  

 

x, y = symbols ( ` xy` )

 
# Using the sympy.combinatorics.Partition.from_rgs () method

gfg = Partition.from_rgs ([ 0 , 1 , 2 , 0 , 1 , 2 ] , list ( `abcdef` ))

 

print (gfg)

Output:

{{ a, d}, {b, e}, {c, f}}

Example # 2:

# import sympy and Relational

from sympy.combinatorics.partitions import Partition

from sympy import *  

  

x, y = symbols ( `xy` )

  
# Using the sympy.combinatorics.Partition.from_rgs () method

gfg = Partition.from_rgs ([ 0 , 1 , 2 , 0 , 1 , 2 , 3 , 4 , 3 , 4 , 0 , 1 , 5 ],

  list ( `abcdefghijklm` ))

 

print (gfg)

Output:

{{m}, {c, f}, {g, i}, {h, j}, {a, d, k}, { b, e, l}}