All problems
Repetition Majority Decode
Problem
Decode a repetition code by majority vote: return 1 when the list contains more ones than zeros and 0 otherwise. Assume the list has odd length.
Hint
Compare twice the number of ones against the length.
Test cases
case 1
in: [[1,1,1]]
expected: 1
case 2
in: [[0,0,0]]
expected: 0
case 3
in: [[1,0,1]]
expected: 1
case 4
in: [[0,0,1]]
expected: 0
case 5
in: [[1,0,0,1,1]]
expected: 1
Starter codePython
def repetition_majority_decode(bits):
# Your code here
pass5 test cases · run your code against them in the editor