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
425 B
19 lines
425 B
from os import readlink |
|
|
|
|
|
f = open ('input2.txt', 'r') |
|
input = f.readlines() |
|
forward = 0 |
|
depth = 0 |
|
for i in range(len(input)): |
|
input[i] = input[i].strip() |
|
for i in range(len(input)): |
|
direct, amount = input[i].split(" ", 1) |
|
if direct == 'forward': |
|
forward += int(amount) |
|
if direct == 'down': |
|
depth += int(amount) |
|
if direct == 'up': |
|
depth -= int(amount) |
|
x = depth * forward |
|
print(x)
|
|
|