Linear Algebra

Sort by

recency

|

303 Discussions

|

  • + 0 comments
    import numpy as np
    N = int(input())
    A = np.array([input().split() for _ in range(N)],float)
    print(round(np.linalg.det(A),2))
    
  • + 0 comments

    import sys import numpy as np

    As usual with HackerRank problems, N is unnecessary.

    However, this time I felt like using it as an example

    of checking the input.

    print([(N := int(input())),

    np.linalg.det(np.loadtxt(sys.stdin.readlines(), float)[:N, :N]).round(2)][1])****

  • + 0 comments
    import numpy as np
    
    n = int(input())
    a = [list(map(float, input().split())) for _ in range(n)]
    
    det = np.linalg.det(a)
    print(round(det, 2))
    
  • + 0 comments

    My compact solution…

    import sys
    import numpy as np
    
    # As usual with HackerRank problems, `N` is unnecessary.
    # However, this time I felt like using it as an example
    # of checking the input.
    
    print([(N := int(input())),
        np.linalg.det(np.loadtxt(sys.stdin.readlines(), float)[:N, :N]).round(2)][1])
    
  • + 0 comments
    import numpy
    print(round(numpy.linalg.det(numpy.array([list(map(float, input().split())) for i in range(int(input()))])), 2))