All problems
Bitset AND OR XOR Different Sizes
Problem
Apply bitwise operations to two bitsets of different lengths.
Shorter bitsets are padded with zeros at the high-index end so the operands align. Compute the AND, OR, and XOR over the padded length.
Return [and_bits, or_bits, xor_bits].
Hint
Padding with leading zeros is equivalent to treating missing positions as 0.
Test cases
case 1
in: [[1,0,1],[1,1]]
expected: [[1,0,0],[1,1,1],[0,1,1]]
case 2
in: [[],[]]
expected: [[],[],[]]
case 3
in: [[1,1],[1,1,1]]
expected: [[1,1,0],[1,1,1],[0,0,1]]
case 4
in: [[0],[1]]
expected: [[0],[1],[1]]
Starter codePython
def bitset_logical(a, b):
# Your code here
pass4 test cases · run your code against them in the editor