SymPy | Subset.unrank_gray() in Python
Last Updated :
28 Aug, 2019
Subset.unrank_gray() : unrank_gray() is a sympy Python library function that returns the Gray code ordered subset of the specified rank.
Syntax :
sympy.combinatorics.subset.Subset.unrank_gray()
Return :
the Gray code ordered subset of the specified rank.
Code #1 : unrank_gray() Example
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
a = Subset.unrank_gray( 4 , ([ 'geek' , 'for' , 'c' , 'd' ]))
print ( "Subset a unrank_gray : " , a.subset)
|
Output :
Subset a unrank_gray : [‘for’, ‘c’]
Code #2 : unrank_gray() Example
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
a = Subset.unrank_gray( 4 , ([ 2 , 3 , 4 ]))
print ( "Subset a unrank_gray : " , a.subset)
|
Output :
Subset a unrank_gray : [2, 3]
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...