advent/2021/2/1.py
2022-07-02 16:31:33 -05:00

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)