All problems
Int4 Pair Unpacking
Problem
Unpack one byte into two 4-bit codes as [low_nibble, high_nibble], the inverse of int4 pair packing.
The signature is int4_pair_unpack(byte).
Hint
Mask the low 4 bits, then shift the byte right by 4 for the second code.
Test cases
case 1
in: [83]
expected: [3,5]
case 2
in: [240]
expected: [0,15]
case 3
in: [15]
expected: [15,0]
case 4
in: [0]
expected: [0,0]
Starter codePython
def int4_pair_unpack(byte):
# Your code here
pass4 test cases · run your code against them in the editor