2021/2 challenge

This commit is contained in:
randomuser 2022-07-02 16:31:33 -05:00
parent 9e5f2d5494
commit c29460a0a9
4 changed files with 1041 additions and 0 deletions

16
2021/2/1.py Normal file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
inputs = [i.rstrip().split(' ') for i in open("input").readlines()]
depth = 0
horiz = 0
for i in inputs:
inst = i[0]
qty = int(i[1])
if(inst == "forward"): horiz += qty
if(inst == "down"): depth += qty
if(inst == "up"): depth -= qty
print(depth, horiz, depth*horiz)

19
2021/2/2.py Normal file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env python3
inputs = [i.rstrip().split(' ') for i in open("input").readlines()]
aim = 0
depth = 0
horiz = 0
for i in inputs:
inst = i[0]
qty = int(i[1])
if(inst == "forward"):
horiz += qty
depth += aim * qty
if(inst == "down"): aim += qty
if(inst == "up"): aim -= qty
print(depth, horiz, depth*horiz)

6
2021/2/example Normal file
View File

@ -0,0 +1,6 @@
forward 5
down 5
forward 8
up 3
down 8
forward 2

1000
2021/2/input Normal file

File diff suppressed because it is too large Load Diff