"""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)