📜  SymPy | Python中的 Permutation.length()

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

SymPy | Python中的 Permutation.length()

Permutation.length() :length()是一个 sympy Python库函数,用于查找由排列移动的整数的数量。

代码 #1:length() 示例

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

输出 :

代码 #2:length() 示例——二维排列

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

输出 :