SymPy | Python中的 Subset.prev_gray()
Subset.prev_gray() :prev_gray()是一个 sympy Python库函数,它返回先前的格雷码有序子集。
Syntax :
sympy.combinatorics.subset.Subset.prev_gray()
Return :
the previous Gray code ordered subset.
代码 #1:prev_gray() 示例
# Python code explaining
# SymPy.Subset.prev_gray()
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
# Using from
# sympy.combinatorics.subset.Subsets.prev_gray()
# Creating Subset
a = Subset(['c', 'd'], ['geek', 'for', 'c', 'd'])
# prev_gray value
print ("Subset a prev_gray : ", a.prev_gray().subset)
输出 :
Subset a prev_gray : [‘d’]
代码 #2:prev_gray() 示例
# Python code explaining
# SymPy.Subset.prev_gray()
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
# Using from
# sympy.combinatorics.subset.Subsets.prev_gray()
# Creating Subset
a = Subset([2, 3, 4], [1, 2, 3, 4, 5])
# prev_gray value
print ("Subset a prev_gray : ", a.prev_gray().subset)
输出 :
Subset a prev_gray : [2, 3, 4, 5]