Finish day02 part 1

This commit is contained in:
Thom Dickson 2021-12-03 17:43:40 -05:00
parent 6ae040193e
commit 9100b0f5d9
Signed by: boots
GPG Key ID: 40BE2AF8EBF8D2BB
2 changed files with 1012 additions and 0 deletions

1000
day02.in Normal file

File diff suppressed because it is too large Load Diff

12
day02.py Normal file
View File

@ -0,0 +1,12 @@
pos = [0, 0]
direction_key = {"forward": (1, 0), "down": (0, 1), "up": (0, -1)}
with open("day02.in") as f:
# fa = [i for i in f]
for x in f:
cmd = x.split()[0]
val = int(x.split()[1])
pos[0] += direction_key[cmd][0] * val
pos[1] += direction_key[cmd][1] * val
print("Current position:", pos)
print("Product:", pos[0] * pos[1])