Skip to content
DeepForgeby svx
All problems
EasyLinear Algebrala-198

Totally Unimodular Check 2x2

Problem

Return True if the 2x2 integer matrix A is totally unimodular: every entry must lie in {-1, 0, 1} and the determinant must lie in {-1, 0, 1}.

Otherwise return False.

Hint

Total unimodularity requires every square submatrix determinant to be 0, 1, or -1.

Test cases

case 1
in: [[[1,1],[1,0]]]
expected: true
case 2
in: [[[1,1],[1,-1]]]
expected: false
case 3
in: [[[1,2],[0,1]]]
expected: false
case 4
in: [[[1,1],[1,1]]]
expected: true
Starter codePython
def is_totally_unimodular_2x2(A):
    # Your code here
    pass

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