filename = "inputs/day2.input" file = open(filename, "rb").readlines() inputs = file horiz = 0 depth = 0 aim = 0 for i in range(len(inputs)): command = inputs[i].decode("utf-8").split() if command[0] == "forward": horiz += int(command[1]) depth += aim * int(command[1]) if command[0] == "up": aim -= int(command[1]) if command[0] == "down": aim += int(command[1]) print(horiz * depth)