Skip to content
DeepForgeby svx
All problems
MediumInformation Theoryinfo-093

Hamming (7,4) Decode

Problem

Correct a single-bit error in a received 7-bit Hamming(7,4) word. Compute the three parity checks, combine them into the position s1 + 2 * s2 + 4 * s4, and flip that 1-indexed bit when the position is nonzero. Return the corrected word.

Hint

A zero syndrome means the word is already a valid codeword.

Test cases

case 1
in: [[1,1,1,0,0,0,0]]
expected: [1,1,1,0,0,0,0]
case 2
in: [[0,1,1,0,0,0,0]]
expected: [1,1,1,0,0,0,0]
case 3
in: [[1,1,1,0,1,0,0]]
expected: [1,1,1,0,0,0,0]
case 4
in: [[0,0,0,0,1,0,0]]
expected: [0,0,0,0,0,0,0]
Starter codePython
def hamming74_decode(received):
    # Your code here
    pass

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