2021/2 challenge
This commit is contained in:
parent
9e5f2d5494
commit
c29460a0a9
|
@ -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)
|
|
@ -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)
|
|
@ -0,0 +1,6 @@
|
|||
forward 5
|
||||
down 5
|
||||
forward 8
|
||||
up 3
|
||||
down 8
|
||||
forward 2
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue