2021/2 challenge
This commit is contained in:
parent
9e5f2d5494
commit
c29460a0a9
16
2021/2/1.py
Normal file
16
2021/2/1.py
Normal 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
19
2021/2/2.py
Normal 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
6
2021/2/example
Normal file
@ -0,0 +1,6 @@
|
||||
forward 5
|
||||
down 5
|
||||
forward 8
|
||||
up 3
|
||||
down 8
|
||||
forward 2
|
1000
2021/2/input
Normal file
1000
2021/2/input
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user