Skip to content
Snippets Groups Projects
Commit fdde8478 authored by VALLET Armel's avatar VALLET Armel
Browse files

question 7

parent 4bc119bb
No related branches found
No related tags found
No related merge requests found
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))
t.plot()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment