📜  Python| SymPy Permutation.cardinality() 方法

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

Python| SymPy Permutation.cardinality() 方法

Permutation.cardinality() :cardinality()是一个 sympy Python库函数,它返回所有可能的排列数。

代码 #1:cardinality() 示例

# Python code explaining
# SymPy.Permutation.cardinality()
  
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
  
# Using from sympy.combinatorics.permutations.Permutation.cardinality() method 
  
# creating Permutation
a = Permutation([[2, 0], [3, 1]])
  
b = Permutation([1, 3, 5, 4, 2, 0])
  
  
print ("Permutation a - cardinality form : ", a.cardinality)
print ("Permutation b - cardinality form : ", b.cardinality)

输出 :

代码 #2:cardinality() 示例– 2D 排列

# Python code explaining
# SymPy.Permutation.cardinality()
  
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.permutations import Permutation
  
# Using from sympy.combinatorics.permutations.Permutation.cardinality() method 
  
# creating Permutation
a = Permutation([[2, 4, 0], 
                 [3, 1, 2],
                 [1, 5, 6]])
  
  
print ("Permutation a - cardinality form : ", a.cardinality)

输出 :