SymPy | Subset.next_gray() in Python
Last Updated :
26 Aug, 2019
Subset.next_gray() : next_gray() is a sympy Python library function that returns the next Gray code ordered subset.
Syntax :
sympy.combinatorics.subset.Subset.next_gray()
Return :
the next Gray code ordered subset
Code #1 : next_gray() Example
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
a = Subset([ 'c' , 'd' ], [ 'geek' , 'for' , 'c' , 'd' ])
print ( "Subset a next_gray : " , a.next_gray().subset)
|
Output :
Subset a next_gray : [‘c’]
Code #2 : next_gray() Example
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
a = Subset([ 'k' , 'd' ], [ '23' , 'k' , 'd' ])
print ( "Subset a next_gray : " , a.next_gray().subset)
|
Output :
Subset a next_gray : [‘k’]
Share your thoughts in the comments
Please Login to comment...