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