Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

HackerRank Linear Algebra problem solution in python

YASH PAL, 31 July 2024

In this Linear Algebra problem, You are given a square matrix A with dimensions N X N. Your task is to find the determinant. Note: Round the answer to 2 places after the decimal.

HackerRank Linear Algebra solution in python

Problem solution in Python 2 programming.

import numpy
import sys

lineNum = 0
matrix = []
for line in sys.stdin:
    if lineNum==0:
        m_size = int(line)
    else:
        matrix.append(map(float,line.split()))
    lineNum+=1

print numpy.linalg.det(matrix)

Problem solution in Python 3 programming.

import numpy
n=int(input())
a=numpy.array([input().split() for _ in range(n)],float)
numpy.set_printoptions(legacy='1.13') #important
print(numpy.linalg.det(a))

Problem solution in pypy programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import numpy
n = int(raw_input())
arr = [map(float, raw_input().split()) for _ in range(n)]
print numpy.linalg.det(arr)

Problem solution in pypy3 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import numpy

n = int(input().strip())
array = []
for _ in range(n):
    array.append([float(x) for x in input().strip().split(' ')])
print(numpy.linalg.det(array))

coding problems python

Post navigation

Previous post
Next post
  • HackerRank Separate the Numbers solution
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
©2025 Programming101 | WordPress Theme by SuperbThemes