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() 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() 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" +