Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-009

3x3 Matrix Determinant

Problem

Compute the determinant of a 3x3 matrix using cofactor expansion along the first row:

det = A[0][0] * M00 - A[0][1] * M01 + A[0][2] * M02

where M0j is the 2x2 minor obtained by deleting row 0 and column j.

Hint

Expand along the first row, alternating signs.

Test cases

case 1
in: [[[1,2,3],[4,5,6],[7,8,9]]]
expected: 0
case 2
in: [[[6,1,1],[4,-2,5],[2,8,7]]]
expected: -306
case 3
in: [[[1,0,0],[0,1,0],[0,0,1]]]
expected: 1
Starter codePython
def det_3x3(A):
    # Your code here
    pass

3 test cases · run your code against them in the editor