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

23
day_2/code.py Normal file
View file

@ -0,0 +1,23 @@
import fileinput
data = []
for inp in fileinput.input():
val = inp.strip()
if val != '':
cmd, v = val.split()
data.append((cmd, int(v)))
horizontal = 0
aim = 0
depth = 0
for cmd, val in data:
if cmd == 'forward':
horizontal+=val
depth+=aim*val
if cmd == 'down':
aim+=val
if cmd == 'up':
aim-=val
print(horizontal, depth)
print(horizontal* depth)

6
day_2/input1.txt Normal file
View file

@ -0,0 +1,6 @@
forward 5
down 5
forward 8
up 3
down 8
forward 2

1001
day_2/input2.txt Normal file

File diff suppressed because it is too large Load diff