Open In App

SymPy | Subset.next_gray() in Python

Last Updated : 26 Aug, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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’]



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads