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: ...@@ -60,20 +60,10 @@ class Polynomial:
a = list(self.value) a = list(self.value)
b = list(other.value) b = list(other.value)
a_count = len(a) c = []
b_count = len(b) # itertools pad 0 to the lowest list
if a_count > b_count: for (a, b) in itertools.zip_longest(a, b, fillvalue=0):
diff = a_count - b_count c.append(a + b)
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]
return Polynomial(tuple(c)) return Polynomial(tuple(c))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment