📜  Python| SymPy Permutation.ascents() 方法

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

Python| SymPy Permutation.ascents() 方法

Permutation.ascents() : ascents()是一个 sympy Python库函数,它返回排列中上升的位置。
上升是 a[i] < a[i+1] 的元素

代码 #1:ascents() 示例

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

输出 :

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

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

输出 :