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