Permutation.index() : index() es una función de biblioteca de Python que devuelve el valor de índice de la permutación en el argumento.
Índice de una permutación = Suma de todos los subíndices j tales que permutación[j] es mayor que permutación[j+1].
Sintaxis:
sympy.combinatorics.permutations.Permutation.index()Retorno:
valor de índice de la permutación
Código #1: index() Ejemplo
# Python code explaining # SymPy.Permutation.index() # importing SymPy libraries from sympy.combinatorics.partitions import Partition from sympy.combinatorics.permutations import Permutation # Using from sympy.combinatorics.permutations.Permutation.index() method # creating Permutation a = Permutation([[2, 0], [3, 1]]) b = Permutation([1, 3, 5, 4, 2, 0]) print ("Permutation a - index form : ", a.index()) print ("Permutation b - index form : ", b.index())
Producción :
Permutación a – forma de índice: 1
Permutación b – forma de índice: 9
Código #2: index() Ejemplo – Permutación 2D
# Python code explaining # SymPy.Permutation.index() # importing SymPy libraries from sympy.combinatorics.partitions import Partition from sympy.combinatorics.permutations import Permutation # Using from sympy.combinatorics.permutations.Permutation.index() method # creating Permutation a = Permutation([[2, 4, 0], [3, 1, 2], [1, 5, 6]]) print ("Permutation a - index form : ", a.index())
Producción :
Permutación a – forma de índice: 8
Publicación traducida automáticamente
Artículo escrito por noobestars101 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA