The error is still with the calculation for the degree of the resulting polynomial! Let’s just take a step back and work out some things mathematically.
Let’s say I have two polynomials:
f(x) = a + bx + cx^2,
and
g(x) = \alpha + \beta x,
where a, b, c, \alpha, \beta are all real numbers for the sake of the argument. If we’re coding this in the context of this problem in the codebook,
len(f) = 3
len(g) = 2
Let’s multiply f and g:
\begin{align*}
h(x) = f(x) \times g(x) & = \alpha (a + bx + cx^2) + \beta x (a + bx + cx^2) \\
& = \alpha a + (\alpha b + \beta a)x + (\alpha c + \beta b)x^2 + \beta c x^3
\end{align*}
This new polynomial h has len(h) = 4
.
Now in your code that you posted,
len(h) = len(f) + len(g) + 1
this won’t give len(h) = 4
! You’re going to get len(h) = 3 + 2 + 1 = 6
, which is not correct. You just need to change how you’re calculating this quantity slightly to get the correct answer :).