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.
19 lines
286 B
19 lines
286 B
2 years ago
|
aim = 0
|
||
|
depth = 0
|
||
|
forw = 0
|
||
|
|
||
|
for s in open("input.txt", 'r').read().splitlines():
|
||
|
split = s.split()
|
||
|
match split[0]:
|
||
|
case "forward":
|
||
|
i = int(split[1])
|
||
|
forw += i
|
||
|
depth += aim * i
|
||
|
case "down":
|
||
|
aim += int(split[1])
|
||
|
case "up":
|
||
|
aim -= int(split[1])
|
||
|
|
||
|
print(depth*forw)
|
||
|
|