Skip to content
DeepForgeby svx
All problems
HardLinear Algebrala-043

Adjugate Matrix 3x3

Problem

Compute the adjugate (classical adjoint) of a 3x3 matrix A.

adj(A) is the transpose of the cofactor matrix: adj(A)[i][j] = cofactor C[j][i], where C[i][j] = (-1)^(i+j) * det(minor(A, i, j)).

Hint

Build the cofactor matrix first, then transpose it.

Test cases

case 1
in: [[[1,0,0],[0,1,0],[0,0,1]]]
expected: [[1,0,0],[0,1,0],[0,0,1]]
case 2
in: [[[1,2,3],[0,1,4],[5,6,0]]]
expected: [[-24,18,5],[20,-15,-4],[-5,4,1]]
case 3
in: [[[2,0,0],[0,3,0],[0,0,4]]]
expected: [[12,0,0],[0,8,0],[0,0,6]]
case 4
in: [[[1,2,3],[4,5,6],[7,8,9]]]
expected: [[-3,6,-3],[6,-12,6],[-3,6,-3]]
Starter codePython
def adjugate_3x3(A):
    # Your code here
    pass

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