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