-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjetTut.py
More file actions
68 lines (53 loc) · 1.79 KB
/
ProjetTut.py
File metadata and controls
68 lines (53 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from tkinter import *
#Sens direct de la bijection entre une permutation et deux tableaux de Young
def permutationToYoung(tab) :
P=[[]]
Q=[[]]
for i in range(len(tab)) :
x,y=insert(tab[i],P)
if (x==len(Q)) :
Q.append([])
Q[x].append(i+1)
return [P,Q]
def insert(elmt,tab,i=0) :
j=0
if (i==len(tab)) :
tab.append([])
while (j<len(tab[i]) and tab[i][j]<elmt) :
j=j+1
if (j==len(tab[i])) :
tab[i].append(elmt)
return i,j
else :
tmp=tab[i][j]
tab[i][j]=elmt
return insert(tmp,tab,i+1)
def RS() :
fenetre=Tk()
fenetre.title("On est trop forts <3")
n=15
c=50
can=Canvas(fenetre,width=n*c,height=n*c, bg="white")
can.pack()
n=int(input("n = "))
permut=[]
for i in range (n) :
print("Sur quoi envoie",i+1,end='')
permut.append(int(input(" ? : ")))
[P,Q]=permutationToYoung(permut) #Tab de Young
for j in range(len(P)) :
y=0 #affichage
for i in range(0,len(P[j])) :
can.create_rectangle(y,j*50,50+y,50+j*50,fill="black")
can.create_rectangle(y+1,j*50+1,49+y,49+j*50,fill="white")
can.create_text(25+y,25+j*50,text=P[j][i],fill="blue")
y=y+50
for j in range(len(Q)) :
y=0 #affichage
for i in range(0,len(Q[j])) :
can.create_rectangle(y,j*50+500,50+y,50+j*50+500,fill="black")
can.create_rectangle(y+1,j*50+1+500,49+y,49+j*50+500,fill="white")
can.create_text(25+y,25+j*50+500,text=Q[j][i],fill="blue")
y=y+50
can.create_text(len(P[0])*50+50,100,font=("Arial",30),text="P",fill="green")
can.create_text(len(P[0])*50+50,600,font=("Arial",30),text="Q",fill="green")