diff --git a/main.py b/main.py index d92f25dff21eb356aaffbce55afd5ec9e78b77ff..cc7028322dce946c2b12dbfead34bcb9c3ffaba6 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,5 @@ +import matplotlib.pyplot as plt + class TabletteChocolat: def __init__(self, m, n): if type(m) != int or type(n) != int: @@ -25,11 +27,23 @@ class TabletteChocolat: def coupe(self, i, j): return TabletteChocolat(self.m - i, self.n - j) + def plot(self): + for i in range(self.m): + for j in range(self.n): + plt.plot((i, i+1, i+1, i, i), (j, j, j+1, j+1, j), color='black') + if i == self.m -1 and j == 0: + plt.fill((i, i + 1, i + 1, i, i), (j, j, j + 1, j + 1, j), color='black') + plt.gca().set_aspect('equal') + plt.axis('off') + plt.show() + plt.close() + # Programme principal -t = TabletteChocolat(5, 2) +t = TabletteChocolat(4, 3) print(t) TabletteChocolat(3, 4) print(t.coups_possibles()) print(t.est_possible(0, 1)) -print(t.coupe(3, 1)) \ No newline at end of file +print(t.coupe(3, 1)) +t.plot() \ No newline at end of file