Skip to content
Snippets Groups Projects
Commit c935c2d2 authored by BAHOU Mehdi's avatar BAHOU Mehdi
Browse files

Question 7

parent e9e42a67
No related branches found
No related tags found
No related merge requests found
#Imports éventuels
from itertools import chain
import matplotlib.pyplot as plt
#Déclaration des classes et des fonctions
class TabletteChocolat:
......@@ -55,11 +56,30 @@ class TabletteChocolat:
return TabletteChocolat(self.m - i, self.n - j)
else:
raise ValueError('Coup impossible')
def plot(self):
m=self.m
n=self.n
plt.fill([0,m,m,0,0],[0,0,n,n,0], color='#D5B799')
for i in range(m):
for j in range(n):
X = [i+0.1, i+0.1, i+0.9, i+0.9, i+0.1]
Y = [j+0.1, j+0.9, j+0.9, j+0.1, j+0.1]
plt.plot(X,Y, color='#000')
n = 0
m -=1
plt.fill([m+0.1, m+0.1, m+0.9, m+0.9, m+0.1], [n+0.1, n+0.9, n+0.9, n+0.1, n+0.1], color='#000')
plt.gca().set_aspect('equal')
plt.axis('off')
plt.show()
plt.close()
#Programme Principal
Tablette = TabletteChocolat(3,4)
Tablette = TabletteChocolat(4,3)
print(Tablette)
g= Tablette.coups_possibles()
print(list(g))
print(Tablette.est_possible(1,0))
biscuit = Tablette.coupe(1,0)
Tablette.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