# Python-divide-and-conquer-assignment

``````def add(poly1, poly2):
try:
if len(poly1) and len(poly2) != 0:
result = [0] * max(len(poly1), len(poly2))
for i in range(len(result)):
if i < len(poly1):
result[i] += poly1[i]
if i < len(poly2):
result[i] += poly2[i]
return result
else:
return "Please Enter two list with valid elements"
except TypeError:

def split(poly1, poly2):
try:
if len(poly1) and len(poly2) != 0:
"""Split each polynomial into two smaller polynomials"""
mid = max(len(poly1), len(poly2)) // 2
return  (poly1[:mid], poly1[mid:]), (poly2[:mid], poly2[mid:])
else:
return "Please Enter two list with valid elements"
except TypeError:

def increase_exponent(poly, n):
try:
if len(poly)!= 0:
"""Multiply poly1 by x^n"""
return [0] * n + poly
else:
return "Please Enter a list with valid elements"
except TypeError:

def multiply_optimized(poly1, poly2):
try:
if len(poly1) and len(poly2) != 0:
m = len(poly1)
n = len(poly2)
result = [0]*(m+n-1)
for i in range(m):
for j in range(n):
result[i+j] += poly1[i]*poly2[j]
return result
else:
return "Please Enter two list with valid elements"
except TypeError: