Open In App
Related Articles

SymPy | Subset.next_gray() in Python

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
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’]


Last Updated : 26 Aug, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads