Open In App
Related Articles

SymPy | Subset.iterate_graycode() in Python

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
Subset.iterate_graycode() : iterate_graycode() is a sympy Python library function that iterates over the k steps to get the respective Gray codes.
Syntax : sympy.combinatorics.subset.Subset.iterate_graycode() Return : iterates over the k steps to get the respective Gray codes
Code #1 : iterate_graycode() Example
# Python code explaining
# SymPy.Subset.iterate_graycode()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.iterate_graycode()
  
# Creating Subset
a = Subset(['c', 'd'], ['geek', 'for', 'c', 'd'])
  
# iterate_graycode value
print ("Subset a iterate_graycode : ", a.iterate_graycode(1).subset)

                    
Output :
Subset a iterate_graycode : [‘c’]
Code #2 : iterate_graycode() Example
# Python code explaining
# SymPy.Subset.iterate_graycode()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.iterate_graycode()
  
# Creating Subset
a = Subset(['c', 'd'], ['23', 'c', 'd'])
  
# iterate_graycode value
print ("Subset a iterate_graycode : ", a.iterate_graycode(3).subset)

                    
Output :
Subset a iterate_graycode : [’23’, ‘c’, ‘d’]


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