This function receives as a parameter an integer and should return a list representing the same value expressed in binary as a list of bits, where the first element in the l
Just sharing a function that processes an array of ints:
def to_binary_string(x):
length = len(bin(max(x))[2:])
for i in x:
b = bin(i)[2:].zfill(length)
yield [int(n) for n in b]
Test:
x1 = to_binary_string([1, 2, 3])
x2 = to_binary_string([1, 2, 3, 4])
print(list(x1)) # [[0, 1], [1, 0], [1, 1]]
print(list(x2)) # [[0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0]]