From fed2ebc39f835299f3c23bc5bc5301552ab4c32a Mon Sep 17 00:00:00 2001 From: BiocheH <quentin.hartman13@gmail.com> Date: Fri, 10 Jan 2025 14:06:37 +0100 Subject: [PATCH] =?UTF-8?q?q7=20:=20ajout=20de=20plot=20(et=20d=C3=A9but?= =?UTF-8?q?=20de=20demander=5Fcoup)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/main.py b/main.py index dd493ec..755f306 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,7 @@ # rendu de Quentin Hartman from itertools import chain +import matplotlib.pyplot as plt class TabletteChocolat: @@ -40,6 +41,23 @@ class TabletteChocolat: ''' return TabletteChocolat(self.m - couple[0], self.n - couple[1]) + def plot(self): + plt.gca().set_aspect('equal') + plt.axis('off') + plt.fill([0, self.m, self.m, 0], [0, 0, self.n, self.n], color='#D5B799') + for i in range(self.m): + for j in range(self.n): + plt.plot([i+0.1, i+0.9, i+0.9, i+0.1, i+0.1], [j+0.1, j+0.1, j+0.9, j+0.9, j+0.1], color='#554739') + plt.fill([self.m-0.9, self.m-0.1, self.m-0.1, self.m-0.9], [0.1, 0.1, 0.9, 0.9], color='#554739') + plt.show() + + def demander_coup(self): + coup = '' + while not coup in ['l', 'c']: + coup = str(input('Couper des lignes (l) ou des colonnes (c) ? ')) + if coup == 'l': + print('voici les coups possibles : ', str(self.coups_possibles())) + A = TabletteChocolat(1, 2) B = TabletteChocolat(4, 8) @@ -51,3 +69,4 @@ print(B.est_possible((3, 0))) print(B.est_possible((3, 2))) print(B.coupe((0, 5))) print(B.coupe((2, 0))) +B.plot() -- GitLab