All problems
Permanent 2x2
Problem
Compute the permanent of a 2x2 matrix: like the determinant but with all signs positive.
perm(A) = A[0][0]*A[1][1] + A[0][1]*A[1][0]
Hint
Only the sign of the second term differs from the determinant.
Test cases
case 1
in: [[[1,2],[3,4]]]
expected: 10
case 2
in: [[[2,0],[0,3]]]
expected: 6
case 3
in: [[[1,-1],[2,3]]]
expected: 1
case 4
in: [[[0,1],[0,0]]]
expected: 0
Starter codePython
def permanent_2x2(A):
# Your code here
pass4 test cases · run your code against them in the editor