Commit f15a86a5 authored by MOREL Celestin's avatar MOREL Celestin
Browse files

avec le script de la partie 1 c est mieux

parent 00b6f810
......@@ -34,13 +34,10 @@ with open('day05/exo5.txt','r') as file:
if a:
instruction = ligne.split(' ')
n = [int(instruction[1]),int(instruction[3]), int(instruction[5][0:-1])]
print(n)
print(matrice)
print(matrice[n[1]-1][(len(matrice[n[1]-1])-n[0])::])
print((len(matrice[n[1]-1])-n[0]))
matrice[n[2]-1]+= matrice[n[1]-1][(len(matrice[n[1]-1])-n[0])::]
del matrice[n[1]-1][ (len(matrice[n[1]-1])-n[0]) ::]
print('#######')
for ele in range(n[0]):
matrice[n[2]-1].append(matrice[n[1]-1].pop())
if ligne == '\n':
......
"""
[G] [D] [Q]
[P] [T] [L] [M] [Z]
[Z] [Z] [C] [Z] [G] [W]
[M] [B] [F] [P] [C] [H] [N]
[T] [S] [R] [H] [W] [R] [L] [W]
[R] [T] [Q] [Z] [R] [S] [Z] [F] [P]
[C] [N] [H] [R] [N] [H] [D] [J] [Q]
[N] [D] [M] [G] [Z] [F] [W] [S] [S]
"""
from time import time
start = time()
matrice = [[] for i in range(9)]
matrice[0] = ['N','C','R','T','M','Z','P']
matrice[1] = ['D','N','T','S','B','Z']
matrice[2] = ['M','H','Q','R','F','C','T','G']
matrice[3] = ['G','R','Z']
matrice[4] = ['Z','N','R','H']
matrice[5] = ['F','H','S','W','P','Z','L','D']
matrice[6] = ['W','D','Z','R','C','G','M']
matrice[7] = ['S','J','F','L','H','W','Z','Q']
matrice[8] = ['S','Q','P','W','N']
with open('day05/exo5.txt','r') as file:
a = False
mot = ''
for ligne in file:
if a:
instruction = ligne.split(' ')
n = [int(instruction[1]),int(instruction[3]), int(instruction[5][0:-1])]
matrice[n[2]-1]+= matrice[n[1]-1][(len(matrice[n[1]-1])-n[0])::]
del matrice[n[1]-1][ (len(matrice[n[1]-1])-n[0]) ::]
print('#######')
if ligne == '\n':
a = True
for i in matrice:
mot +=i[-1]
print(mot)
end = time()
#print(f'points calculés { m }')
print(f'reponse trouvée en {end - start } sec')
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment