This commit is contained in:
Matthieu Bessat 2021-12-05 16:52:20 +01:00
commit 82f8e11ae4
42 changed files with 5836 additions and 0 deletions

14
day_1/code.py Normal file
View file

@ -0,0 +1,14 @@
import fileinput
previous = None
count = 0
for i,line in enumerate(fileinput.input()):
try:
val = int(line.strip())
except ValueError:
continue
if previous != None and val > previous:
count += 1
previous = val
print(count)

18
day_1/code2.py Normal file
View file

@ -0,0 +1,18 @@
import fileinput
data = []
for inp in fileinput.input():
val = inp.strip()
if val != '':
int_value = int(val)
data.append(int_value)
prec = None
count = 0
for i in range(len(data) - 2):
s = data[i]+data[i+1]+data[i+2]
if prec != None and s > prec:
count += 1
prec = s
print(count)

11
day_1/input1.txt Normal file
View file

@ -0,0 +1,11 @@
199
200
208
210
200
207
240
269
260
263

2000
day_1/input2.txt Normal file

File diff suppressed because it is too large Load diff