blob: f6e947532b6d54c3db443a25b2bb92bb1e3f5e6e (
plain) (
blame)
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
|
# Day Two: Dive!
file = open("input/02.txt").readlines()
hori = 0
depth = 0
for line in file:
com = line.split()
if com[0] == "forward":
hori += int(com[1])
if com[0] == "up":
depth -= int(com[1])
if com[0] == "down":
depth += int(com[1])
print(hori * depth)
hori = 0
depth = 0
aim = 0
for line in file:
com = line.split()
if com[0] == "forward":
hori += int(com[1])
depth += aim * int(com[1])
if com[0] == "up":
aim -= int(com[1])
if com[0] == "down":
aim += int(com[1])
print(hori * depth)
|