day 11, 12 + folder refactoring

This commit is contained in:
Matthieu Bessat 2021-12-13 10:08:40 +01:00
parent d9f6c01f2b
commit 06a5771fbf
78 changed files with 1242 additions and 8 deletions

40
06_day/code.py Normal file
View file

@ -0,0 +1,40 @@
db = False
import fileinput
state = []
lines = [l for l in fileinput.input()]
assert(len(lines) > 0)
assert(len(lines[0]) > 0)
rawState = list(map(int, lines[0].split(',')))
state = [0 for i in range(9)]
for s in rawState:
state[s] += 1
days = 256
day = 0
if db:
print(day, ",".join(map(str, state)))
for day in range(1, days+1):
nextState = [0 for i in range(9)]
for i, s in enumerate(state):
if i == 0:
nextState[6] = s
nextState[8] = s
else:
nextState[i-1] += s
state = nextState.copy()
if db:
print(day, ",".join(map(str, state)))
print('===')
print(sum(state))

1
06_day/example.txt Normal file
View file

@ -0,0 +1 @@
3,4,3,1,2

2
06_day/input.txt Normal file
View file

@ -0,0 +1,2 @@
2,1,1,1,1,1,1,5,1,1,1,1,5,1,1,3,5,1,1,3,1,1,3,1,4,4,4,5,1,1,1,3,1,3,1,1,2,2,1,1,1,5,1,1,1,5,2,5,1,1,2,1,3,3,5,1,1,4,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,4,1,5,1,2,1,1,1,1,5,1,1,1,1,1,5,1,1,1,4,5,1,1,3,4,1,1,1,3,5,1,1,1,2,1,1,4,1,4,1,2,1,1,2,1,5,1,1,1,5,1,2,2,1,1,1,5,1,2,3,1,1,1,5,3,2,1,1,3,1,1,3,1,3,1,1,1,5,1,1,1,1,1,1,1,3,1,1,1,1,3,1,1,4,1,1,3,2,1,2,1,1,2,2,1,2,1,1,1,4,1,2,4,1,1,4,4,1,1,1,1,1,4,1,1,1,2,1,1,2,1,5,1,1,1,1,1,5,1,3,1,1,2,3,4,4,1,1,1,3,2,4,4,1,1,3,5,1,1,1,1,4,1,1,1,1,1,5,3,1,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,1,1,1,1,1,1,1,1,5,1,4,4,1,1,1,1,1,1,1,1,3,1,3,1,4,1,1,2,2,2,1,1,2,1,1