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