📜  SymPy | Python中的 Subset.next_gray()

📅  最后修改于: 2022-05-13 01:54:18.977000             🧑  作者: Mango

SymPy | Python中的 Subset.next_gray()

Subset.next_gray() :next_gray()是一个 sympy Python库函数,它返回下一个格雷码有序子集。

代码 #1:next_gray() 示例

# 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)

输出 :

代码 #2:next_gray() 示例

# 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)

输出 :