From c35124aba6ed2a09f489901ace397ecfb4bceabf Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 20 Nov 2023 14:31:04 +0100 Subject: [PATCH] vault backup: 2023-11-20 14:31:04 --- Algo/B2/Exercises/Repetitive tutorial.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Algo/B2/Exercises/Repetitive tutorial.md b/Algo/B2/Exercises/Repetitive tutorial.md index ac8a4d8..c0e3037 100644 --- a/Algo/B2/Exercises/Repetitive tutorial.md +++ b/Algo/B2/Exercises/Repetitive tutorial.md @@ -32,6 +32,18 @@ def multiplication2(x: int, y: int) -> int: # Thanks Hugo :p else return multiplication(x, y) +def productZ(x, y): + pos = True + if x < 0: + x = -x + pos = False + if y < 0: + y = -y + pos = not pos + m = multiplication(x, y) + if not pos: + m = -m + return m ``` ## Exercise 1.3