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

add modulo

parent 610cb0bc
No related branches found
No related tags found
No related merge requests found
...@@ -54,7 +54,13 @@ class Polynomial: ...@@ -54,7 +54,13 @@ class Polynomial:
return Polynomial(tuple(c)) return Polynomial(tuple(c))
def __mod__(self, other): 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): def __str__(self):
str_value = "" str_value = ""
...@@ -90,6 +96,8 @@ def main(): ...@@ -90,6 +96,8 @@ def main():
print(p1) print(p1)
print(p2) print(p2)
print(p3) print(p3)
print(p3%4)
print(p3%5)
with open("messages.json") as f: with open("messages.json") as f:
messages = json.load(f) messages = json.load(f)
...@@ -104,4 +112,4 @@ def main(): ...@@ -104,4 +112,4 @@ def main():
if __name__ == "__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