day 11, 12 + folder refactoring
This commit is contained in:
parent
d9f6c01f2b
commit
06a5771fbf
78 changed files with 1242 additions and 8 deletions
23
02_day/code.py
Normal file
23
02_day/code.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import fileinput
|
||||
|
||||
data = []
|
||||
for inp in fileinput.input():
|
||||
val = inp.strip()
|
||||
if val != '':
|
||||
cmd, v = val.split()
|
||||
data.append((cmd, int(v)))
|
||||
|
||||
horizontal = 0
|
||||
aim = 0
|
||||
depth = 0
|
||||
for cmd, val in data:
|
||||
if cmd == 'forward':
|
||||
horizontal+=val
|
||||
depth+=aim*val
|
||||
if cmd == 'down':
|
||||
aim+=val
|
||||
if cmd == 'up':
|
||||
aim-=val
|
||||
print(horizontal, depth)
|
||||
|
||||
print(horizontal* depth)
|
||||
6
02_day/input1.txt
Normal file
6
02_day/input1.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
forward 5
|
||||
down 5
|
||||
forward 8
|
||||
up 3
|
||||
down 8
|
||||
forward 2
|
||||
1001
02_day/input2.txt
Normal file
1001
02_day/input2.txt
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue