Skip to content
DeepForgeby svx
All problems
HardInformation Theoryinfo-103

CRC Remainder

Problem

Compute the CRC remainder by binary polynomial long division. Append len(poly) - 1 zero bits to data, then for every position where the current leading bit is 1, XOR the polynomial into the window starting there. Return the final len(poly) - 1 remainder bits.

Hint

The polynomial always starts with a leading 1, so XOR clears the leading bit.

Test cases

case 1
in: [[1,1,0,1],[1,0,1,1]]
expected: [0,0,1]
case 2
in: [[1,0,1],[1,1,0,1]]
expected: [1,1,0]
case 3
in: [[1],[1,1]]
expected: [1]
case 4
in: [[1,0,1,0,1],[1,0,1]]
expected: [0,1]
case 5
in: [[0,0,0],[1,0,1]]
expected: [0,0]
Starter codePython
def crc_remainder(data, poly):
    # Your code here
    pass

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