advent/2021/2/1.py

17 lines
314 B
Python
Raw Normal View History

2022-07-02 16:31:33 -05:00
#!/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)