Skip to content
Related Articles

Related Articles

SymPy | Subset.next_gray() in Python

Improve Article
Save Article
Like Article
  • 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




# Python code explaining
# SymPy.Subset.next_gray()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.next_gray()
  
# Creating Subset
a = Subset(['c', 'd'], ['geek', 'for', 'c', 'd'])
  
# next_gray value
print ("Subset a next_gray : ", a.next_gray().subset)

Output :

Subset a next_gray : [‘c’]

Code #2 : next_gray() Example




# Python code explaining
# SymPy.Subset.next_gray()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.next_gray()
  
# Creating Subset
a = Subset(['k', 'd'], ['23', 'k', 'd'])
  
# next_gray value
print ("Subset a next_gray : ", a.next_gray().subset)

Output :

Subset a next_gray : [‘k’]


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!