]> git.friedersdorff.com Git - max/advent_of_code_2021.git/blob - 2_2.py
Try day 14
[max/advent_of_code_2021.git] / 2_2.py
1 """Calculate the final position of the submarine"""
2
3 aim = 0
4 horizonal = 0
5 depth = 0
6 with open("2_1_input.txt") as f:
7     for line in f:
8         command, distance = line.split(" ")
9         distance = int(distance)
10
11         if command == "down":
12             aim += distance
13         elif command == "up":
14             aim -= distance
15         elif command == "forward":
16             horizonal += distance
17             depth += aim * distance
18         else:
19             raise RuntimeError("you fucked it captain")
20
21 print(horizonal, depth, horizonal * depth)