Skip to content
Snippets Groups Projects
Commit 2b49e4b0 authored by gawen.ackerman's avatar gawen.ackerman :robot:
Browse files

refactoring add

parent 0a54aa2d
No related branches found
No related tags found
No related merge requests found
......@@ -60,20 +60,10 @@ class Polynomial:
a = list(self.value)
b = list(other.value)
a_count = len(a)
b_count = len(b)
if a_count > b_count:
diff = a_count - b_count
for x in range(diff):
b.append(0)
else:
diff = b_count - a_count
for x in range(diff):
a.append(0)
c = [0] * len(a)
for x in range(len(a)):
c[x] = a[x] + b[x]
c = []
# itertools pad 0 to the lowest list
for (a, b) in itertools.zip_longest(a, b, fillvalue=0):
c.append(a + b)
return Polynomial(tuple(c))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment