SymPy | Python中的 Subset.rank_lexicographic()
Subset.rank_lexicographic() : rank_lexicographic()是一个 sympy Python库函数,它返回子集的词典排序。
Syntax :
sympy.combinatorics.subset.Subset.rank_lexicographic()
Return :
the lexicographic ranking of the subset.
代码 #1:rank_lexicographic() 示例
# Python code explaining
# SymPy.Subset.rank_lexicographic()
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
# Using from
# sympy.combinatorics.subset.Subsets.rank_lexicographic()
# Creating Subset
a = Subset(['c', 'd'], ['geek', 'for', 'c', 'd'])
# rank_lexicographic value
print ("Subset a rank_lexicographic : ", a.rank_lexicographic)
输出 :
Subset a rank_lexicographic : 14
代码 #2:rank_lexicographic() 示例
# Python code explaining
# SymPy.Subset.rank_lexicographic()
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
# Using from
# sympy.combinatorics.subset.Subsets.rank_lexicographic()
# Creating Subset
a = Subset([2, 3, 4], [1, 2, 3, 4, 5])
# rank_lexicographic value
print ("Subset a rank_lexicographic : ", a.rank_lexicographic)
输出 :
Subset a rank_lexicographic : 19