Test_case 15 : failed

def subtract(poly1,poly2):
poly2 = [-i for i in poly2]
return add(poly1,poly2)

def multiply_optimized(poly1, poly2):
m = len(poly1)
n = len(poly2)

if poly1 == []:
    return []
if poly2 == []:
    return []

if m == 1 or n == 1:
    if poly1[0] == 0 or poly2[0] == 0:
        return [0]
    
if m == 1:
    return [poly1[0] * i for i in poly2]
elif n == 1:
    return [poly2[0] * i for i in poly1]

if all(p1 == 0 for p1 in poly1) or all(p2 == 0 for p2 in poly2):
    return [0]

n = max(m, n)
n = n if n % 2 == 0 else n - 1

A, B = split(poly1, poly2)

U = multiply_optimized(A[0],B[0])
Z = multiply_optimized(A[1],B[1])
Y = multiply_optimized(add(A[0],A[1]), add(B[0],B[1]))

Y = subtract(Y, add(U, Z))
Y = increase_exponent(Y, n//2)

Z = increase_exponent(Z, n)

return add(add(U, Z), Y)

This is my code, and i am getting a FAILED result only on TEST_CASE 15 while submitting!, please help!

have you got the answer???

1 Like