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.


The linalg.det tool computes the determinant of an array.


The linalg.eig computes the eigenvalues and right eigenvectors of a square array.


The linalg.inv tool computes the (multiplicative) inverse of a matrix.

  1. import numpy as np
  2. np.set_printoptions(legacy='1.13')
  3. n = int(input())
  4. array = np.array([input().split() for _ in range(n)], float)
  5. print(np.linalg.det(array))

download android app