20 lines
353 B
Python
20 lines
353 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
inputs = [i.rstrip().split(' ') for i in open("input").readlines()]
|
||
|
|
||
|
aim = 0
|
||
|
depth = 0
|
||
|
horiz = 0
|
||
|
|
||
|
for i in inputs:
|
||
|
inst = i[0]
|
||
|
qty = int(i[1])
|
||
|
|
||
|
if(inst == "forward"):
|
||
|
horiz += qty
|
||
|
depth += aim * qty
|
||
|
if(inst == "down"): aim += qty
|
||
|
if(inst == "up"): aim -= qty
|
||
|
|
||
|
print(depth, horiz, depth*horiz)
|