--- /dev/null
+"""Calculate the final position of the submarine"""
+
+horizonal = 0
+depth = 0
+with open("2_1_input.txt") as f:
+ for line in f:
+ command, distance = line.split(" ")
+ distance = int(distance)
+
+ if command == "down":
+ depth += distance
+ elif command == "up":
+ depth -= distance
+ elif command == "forward":
+ horizonal += distance
+ else:
+ raise RuntimeError("you fucked it captain")
+
+print(horizonal, depth, horizonal * depth)
--- /dev/null
+"""Calculate the final position of the submarine"""
+
+aim = 0
+horizonal = 0
+depth = 0
+with open("2_1_input.txt") as f:
+ for line in f:
+ command, distance = line.split(" ")
+ distance = int(distance)
+
+ if command == "down":
+ aim += distance
+ elif command == "up":
+ aim -= distance
+ elif command == "forward":
+ horizonal += distance
+ depth += aim * distance
+ else:
+ raise RuntimeError("you fucked it captain")
+
+print(horizonal, depth, horizonal * depth)