From e19fc6544a510015a840d023ebc485926bf9ee29 Mon Sep 17 00:00:00 2001 From: CHOPIN LouAnne SERRET Valentine <lou-anne.chopin@etu.univ-amu.fr> Date: Fri, 10 Jan 2025 14:58:48 +0100 Subject: [PATCH] question 6 --- main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 8ab4156..7c18079 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,4 @@ - - +import matplotlib.pyplot as plt class TabletteChocolat : def __init__(self, m, n): if not isinstance(m, int) or not isinstance(n, int) : @@ -25,8 +24,13 @@ class TabletteChocolat : coup = i, j return 0<= i < self.m and 0 <= j < self.n and self.tablette[i][j] == 1 - - + def coupe(self, i, j): + coup = i, j + if not self.est_possible(coup): + raise ValueError('Coup impossible') + for x in range (i, self.m): + for y in range(j, self.n): + self.tablette[x][y] = 0 t = TabletteChocolat(3, 4) -- GitLab