All problems
Linear Code Rank mod 2
Problem
Return the rank over GF(2) of a binary matrix, computed by Gaussian elimination in which adding two rows means XORing them. The rank is the number of linearly independent rows over the two-element field.
Hint
A row that is the XOR of two others adds no rank.
Test cases
case 1
in: [[[1,0],[0,1]]]
expected: 2
case 2
in: [[[1,1],[1,1]]]
expected: 1
case 3
in: [[[0,0],[0,0]]]
expected: 0
case 4
in: [[[1,1,0],[0,0,1]]]
expected: 2
case 5
in: [[[1,0,1],[0,1,1],[1,1,0]]]
expected: 2
Starter codePython
def gaussian_rank_mod2(matrix):
# Your code here
pass5 test cases · run your code against them in the editor