Solve day02 part 2

This commit is contained in:
Thom Dickson 2021-12-04 15:47:33 -05:00
parent 9100b0f5d9
commit 1e0e651fea
Signed by: boots
GPG Key ID: 40BE2AF8EBF8D2BB
2 changed files with 1017 additions and 0 deletions

1000
day02.in2 Normal file

File diff suppressed because it is too large Load Diff

View File

@ -10,3 +10,20 @@ with open("day02.in") as f:
print("Current position:", pos)
print("Product:", pos[0] * pos[1])
# Part 2
pos = [0, 0, 0]
with open("day02.in2") as f:
for x in f:
cmd = x.split()[0]
val = int(x.split()[1])
if cmd == "down":
pos[2] += val
elif cmd == "up":
pos[2] -= val
elif cmd == "forward":
pos[0] += val
pos[1] += pos[2] * val
print("Current position:", pos)
print("Product:", pos[0] * pos[1])