So in uni we learned how to multiplicate 2 binary codes. After trying in Python and getting the right result, i wanted to know if i can improve my code with less if statements or if i made any major mistakes without recognising.
l1 = [1,1,0,1,1]
l2 = [1,0,0,0,0]
brack = 0
result = []
for i in range(len(l1)):
if l1[i] + l2[i] == 2:
result.append(0)
brack +=1
elif (l1[i] + l2[i] == 1) and (brack == 0):
result.append(1)
elif (l1[i] + l2[i] == 1) and (brack == 1):
result.append(0)
brack -= 1
elif(l1[i] + l2[i] == 0) and (brack == 1):
result.append(0)
brack -= 1
elif(l1[i] + l2[i] == 0) and (brack == 0):
result.append(0)
if (result[-1] == 0):
result.append(1)
print(result)