SymPy | Permutation.inversions() in Python Last Updated : 26 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report Permutation.inversions() : inversions() is a sympy Python library function that returns the number of inversions value of the permutation in the argument. The inversion vector includes those elements whose value indicates the no. of elements in the permutation that are < it and lie on its right-hand side. Syntax : Return : number of inversions value of the permutation in argument Code #1 : inversions() Example Python3 1=1 # Python code explaining # SymPy.Permutation.inversions() # importing SymPy libraries from sympy.combinatorics.partitions import Partition from sympy.combinatorics.permutations import Permutation # Using from # sympy.combinatorics.permutations.Permutation.inversions() method # creating Permutation a = Permutation([[2, 0], [3, 1]]) b = Permutation([1, 3, 5, 4, 2, 0]) print ("Permutation a - inversions form : ", a.inversions()) print ("Permutation b - inversions form : ", b.inversions()) Output : Permutation a - inversions form : 4 Permutation b - inversions form : 9 Code #2 : inversions() Example - 2D Permutation Python3 1=1 # Python code explaining # SymPy.Permutation.inversions() # importing SymPy libraries from sympy.combinatorics.partitions import Partition from sympy.combinatorics.permutations import Permutation # Using from sympy.combinatorics.permutations.Permutation.inversions() method # creating Permutation a = Permutation([[2, 4, 0], [3, 1, 2], [1, 5, 6]]) print ("Permutation a - inversions form : ", a.inversions()) Output : Permutation a - inversions form : 10 Comment More infoAdvertise with us Next Article SymPy | Permutation.inversions() in Python N noobestars101 Follow Improve Article Tags : Python SymPy Practice Tags : python Similar Reads SymPy | Permutation.min() in Python Permutation.min() : min() is a sympy Python library function that returns the minimum value in the permutation. Syntax : sympy.combinatorics.permutations.Permutation.min() Return : minimum value in the permutation Code #1 : min() Example Python3 1=1 # Python code explaining # SymPy.Permutation.min() 1 min read Python | SymPy Permutation.inversion_vector() Permutation.inversion_vector() : inversion_vector() is a sympy Python library function that returns the inversion_vector value of the permutation in argument. The inversion vector includes those elements whose value indicates the no. of elements in the permutation that are < it and lie on its rig 2 min read SymPy | Permutation.list() in Python Permutation.list() : list() is a sympy Python library function that returns the permutation as an explicit list, possibly trimming unmoved elements if size is less than the maximum element in the permutation. Syntax : sympy.combinatorics.permutations.Permutation.list() Return : permutation as an exp 2 min read SymPy | Permutation.is_odd() in Python Permutation.is_odd() : is_odd() is a sympy Python library function that checks whether the permutation is odd. Syntax : sympy.combinatorics.permutations.Permutation.is_odd() Return : true - if the permutation is odd; otherwise false Code #1 : is_odd() Example Python3 1=1 # Python code explaining # S 1 min read SymPy | Permutation.order() in Python Permutation.order() : order() is a sympy Python library function that calculates the order of a permutation. When the permutation is raised to the power of its order, then, in that case, the order equals the identity permutation. Syntax : sympy.combinatorics.permutations.Permutation.order() Return : 1 min read Like