Skip to content
DeepForgeby svx
All problems
EasyInformation Theoryinfo-104

LFSR Step

Problem

Advance a linear feedback shift register by one step. The feedback bit is the XOR of state[i] for every index in taps; the new state is [feedback] followed by the state minus its last bit.

Hint

Each step shifts the register toward the end and injects the feedback at the front.

Test cases

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

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