Skip to content
Snippets Groups Projects
Commit 267ca255 authored by quentin.fasler's avatar quentin.fasler
Browse files

add modulo

parent 610cb0bc
Branches
Tags untagged-45a5d503565c4f0dc073
No related merge requests found
......@@ -54,7 +54,13 @@ class Polynomial:
return Polynomial(tuple(c))
def __mod__(self, other):
pass
a = list(self.value)
result = [0] * len(a)
for i in range(len(a)):
result[i] = a[i] % other
return Polynomial(tuple(result))
def __str__(self):
str_value = ""
......@@ -90,6 +96,8 @@ def main():
print(p1)
print(p2)
print(p3)
print(p3%4)
print(p3%5)
with open("messages.json") as f:
messages = json.load(f)
......@@ -104,4 +112,4 @@ def main():
if __name__ == "__main__":
main()
main()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment