Skip to content
DeepForgeby svx
All problems
MediumInformation Theoryinfo-201

Syndrome Decode Step

Problem

Given a parity-check matrix H and a syndrome vector, return the 0-indexed column of H that equals the syndrome, which identifies the single-bit error position. Return -1 when no column matches.

Hint

For single-error correction each error position gets a unique syndrome column.

Test cases

case 1
in: [[[1,1,0],[0,1,1]],[1,0]]
expected: 0
case 2
in: [[[1,1,0],[0,1,1]],[1,1]]
expected: 1
case 3
in: [[[1,1,0],[0,1,1]],[0,1]]
expected: 2
case 4
in: [[[1,1,0],[0,1,1]],[0,0]]
expected: -1
case 5
in: [[[1,0,1],[0,1,1],[1,1,0]],[0,1,1]]
expected: 1
Starter codePython
def syndrome_decode_step(h_matrix, syndrome):
    # Your code here
    pass

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