You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
436 B

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)