This commit is contained in:
2021-12-01 21:23:22 -08:00
parent 02c8ed3933
commit c898811c9f
3 changed files with 1043 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
with open("input.txt") as f:
lines = [i for i in f.readlines()]
depth = 0
hpos = 0
for line in lines:
verb, val = line.strip().split()
val = int(val)
if verb == "forward":
hpos += val
elif verb == "down":
depth += val
elif verb == "up":
depth -= val
print(depth * hpos)
+24
View File
@@ -0,0 +1,24 @@
with open("input.txt") as f:
lines = [i for i in f.readlines()]
depth = 0
hpos = 0
aim = 0
for line in lines:
verb, val = line.strip().split()
val = int(val)
if verb == "forward":
hpos += val
depth += (aim * val)
elif verb == "down":
aim += val
elif verb == "up":
aim -= val
print(depth * hpos)
# 5m16s
+1000
View File
File diff suppressed because it is too large Load Diff