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.
 
 

15 lines
253 B

depth = 0
forw = 0
for s in open("input.txt", 'r').read().splitlines():
split = s.split()
match split[0]:
case "forward":
forw += int(split[1])
case "down":
depth += int(split[1])
case "up":
depth -= int(split[1])
print(depth*forw)