HackerRank Python - Linear Algebra
The NumPy module also comes with a number of built-in routines for linear algebra calculations. These can be found in the sub-module linalg.
linalg.det
The linalg.det tool computes the determinant of an array.
linalg.eig
The linalg.eig computes the eigenvalues and right eigenvectors of a square array.
linalg.inv
The linalg.inv tool computes the (multiplicative) inverse of a matrix.
- import numpy as np
-
- np.set_printoptions(legacy='1.13')
-
- n = int(input())
- array = np.array([input().split() for _ in range(n)], float)
- print(np.linalg.det(array))