blob: f82eb3a61b2234b54ca166e10c71df769c962f99 (
plain) (
tree)
|
|
#!/usr/bin/env python
depth = 0
dist = 0
with open("day2.txt") as data:
for line in data:
match line.split():
case ["forward", x]:
dist += int(x)
case ["up", x]:
depth -= int(x)
case ["down", x]:
depth += int(x)
print(depth * dist)
depth = 0
dist = 0
aim = 0
with open("day2.txt") as data:
for line in data:
match line.split():
case ["forward", x]:
dist += int(x)
depth += aim * int(x)
case ["up", x]:
aim -= int(x)
case ["down", x]:
aim += int(x)
print(depth * dist)
|