All problems
Repetition Code Encode
Problem
Encode a single bit with a repetition code of length n by returning a list containing that bit n times. Assume bit is 0 or 1 and n >= 1.
Hint
Repetition trades rate for a larger minimum Hamming distance.
Test cases
case 1
in: [1,5]
expected: [1,1,1,1,1]
case 2
in: [0,3]
expected: [0,0,0]
case 3
in: [1,1]
expected: [1]
case 4
in: [0,4]
expected: [0,0,0,0]
Starter codePython
def repetition_encode(bit, n):
# Your code here
pass4 test cases · run your code against them in the editor