From 8670e8e08bee5ab6717cdc3358230b3c83a61f48 Mon Sep 17 00:00:00 2001 From: hibaaff Date: Fri, 27 Sep 2024 12:23:33 +0200 Subject: [PATCH 1/3] Update exo1.py --- exo1/exo1.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/exo1/exo1.py b/exo1/exo1.py index 3034469..b637c54 100644 --- a/exo1/exo1.py +++ b/exo1/exo1.py @@ -7,3 +7,16 @@ Write the code for this class, with the appropriate constructor. Example of code using the class: i = Item(10, 20) """ +class Item: + def __init__(self,weight,price): + self.weight=weight + self.price=price + + def get_price(self): + print('price:',self.price) + def get_weight(self): + print('weight:',self.weight) + +i=Item(10,20) + +i.get_price() From 9e13a6c34aacb0ed48e0081e7dcec3191b2f0341 Mon Sep 17 00:00:00 2001 From: hibaaff Date: Fri, 27 Sep 2024 12:41:45 +0200 Subject: [PATCH 2/3] Update exo2.py --- exo2/exo2.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/exo2/exo2.py b/exo2/exo2.py index 7049e03..d4430a1 100644 --- a/exo2/exo2.py +++ b/exo2/exo2.py @@ -28,3 +28,35 @@ ( "spam", "eggs" ) ) """ +import unittest + +class TestSolution(unittest.TestCase): + + def test_fixed_tests_true(self): + fixed_tests_True = [ + ("samurai", "ai"), + ("ninja", "ja"), + ("sensei", "i"), + ("abc", "abc"), + ("abcabc", "bc"), + ("fails", "ails") + ] + for string, ending in fixed_tests_True: + with self.subTest(string=string, ending=ending): + self.assertTrue(solution(string, ending)) + + def test_fixed_tests_false(self): + fixed_tests_False = [ + ("sumo", "omo"), + ("samurai", "ra"), + ("abc", "abcd"), + ("ails", "fails"), + ("this", "fails"), + ("spam", "eggs") + ] + for string, ending in fixed_tests_False: + with self.subTest(string=string, ending=ending): + self.assertFalse(solution(string, ending)) + +if _name_ == '_main_': + unittest.main() From decc5ba413176fe3b1d7721be9e3f4731afd0855 Mon Sep 17 00:00:00 2001 From: hibaaff Date: Fri, 27 Sep 2024 12:42:39 +0200 Subject: [PATCH 3/3] Update exo3.py --- exo3/exo3.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/exo3/exo3.py b/exo3/exo3.py index 610c44e..52002db 100644 --- a/exo3/exo3.py +++ b/exo3/exo3.py @@ -39,5 +39,19 @@ def processLines(lines) -> str: - # Implementer votre réponse ici - return "OK" + # Lecture des données d'entrée + N = int(lines[0]) # Nombre de sprints + T = int(lines[1]) # Nombre de tâches dans le backlog initial + + # Initialisation du backlog avec T tâches + backlog = T + + # Boucle sur les N sprints pour mettre à jour le backlog + for i in range(2, 2 + N): + V, U = map(int, lines[i].split()) # V est le nombre de tâches validées, U est la variation du backlog + backlog -= V # Retirer les tâches validées + backlog += U # Ajuster avec les tâches ajoutées ou supprimées + + # Si le backlog est vide, on retourne "OK", sinon "KO" + return "OK" if backlog == 0 else "KO" +