SymPy | Prufer.unrank() in Python
Last Updated :
26 Aug, 2019
Prufer.unrank() : unrank() is a sympy Python library function that returns the unranked Prufer sequence.
Syntax :
sympy.combinatorics.Prufer.prufer.unrank()
Return :
unranked Prufer sequence
Code #1 : unrank() Example
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.prufer import Prufer
a = Prufer([ 1 , 2 , 3 ], [ 2 , 4 , 5 ])
print ( "Prufer a unrank : " , a.unrank( 2 , 5 ))
|
Output :
Prufer a unrank : 125
Code #2 : unrank() Example
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.prufer import Prufer
b = Prufer([ 1 , 2 , 3 , 2 , 4 , 5 ], [ 6 , 7 ], [ 8 ])
print ( "Prufer b unrank : " , b.unrank( 2 , 5 ))
|
Output :
Prufer b unrank : Prufer([0, 0, 2])
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...