SymPy | Permutation.unrank_lex() in Python
Last Updated :
27 Aug, 2019
Permutation.unrank_lex() : unrank_lex() is a sympy Python library function that returns the Lexicographic permutation unranking.
Syntax : sympy.combinatorics.permutations.Permutation.unrank_lex()
Return : Lexicographic permutation unranking
Code #1 : unrank_lex() Example
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
a = Permutation([[ 2 , 0 ], [ 3 , 1 ]])
b = Permutation([ 1 , 3 , 5 , 4 , 2 , 0 ])
size = 2
rank = 5
print ( "Permutation a - unrank_lex form : " , a.unrank_lex(size, rank))
print ( "Permutation b - unrank_lex form : " , b.unrank_lex(size, 2 ))
|
Output :
Permutation a – unrank_lex form : (0 1)
Permutation b – unrank_lex form : (1)
Code #2 : unrank_lex() Example
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
a = Permutation([[ 2 , 4 , 0 ],
[ 3 , 1 , 2 ],
[ 1 , 5 , 6 ]])
print ( "Permutation a - unrank_lex form : " , a.unrank_lex( 5 , 2 ))
|
Output :
Permutation a – unrank_lex form : (4)(2 3)
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...