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.
18 lines
365 B
18 lines
365 B
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)
|