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