Advent-of-Code/2021/2/main.py
2021-12-06 14:56:21 -05:00

18 lines
345 B
Python

x = 0 # horizontal position
d = 0 # depth
with open('data', 'r') as fp:
for line in fp:
data = line.split()
if(data[0] == 'forward'):
x = x + int(data[1])
elif(data[0] == 'down'):
d = d + int(data[1])
else:
d = d - int(data[1])
print "x: ", x
print "d: ", d
print " : ", x * d