added day02
This commit is contained in:
parent
f4cdb87eb2
commit
12b1058a27
1000
02/input01.txt
Normal file
1000
02/input01.txt
Normal file
File diff suppressed because it is too large
Load Diff
1000
02/input02.txt
Normal file
1000
02/input02.txt
Normal file
File diff suppressed because it is too large
Load Diff
15
02/solve01.py
Normal file
15
02/solve01.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
pos=[0,0]
|
||||||
|
with open("input01.txt", "r") as f:
|
||||||
|
for line in f:
|
||||||
|
tokens = line.split(" ", 2)
|
||||||
|
tokens[1] = int(tokens[1])
|
||||||
|
if tokens[0] == 'forward':
|
||||||
|
pos[0] += tokens[1]
|
||||||
|
if tokens[0] == 'up':
|
||||||
|
pos[1] -= tokens[1]
|
||||||
|
if tokens[0] == 'down':
|
||||||
|
pos[1] += tokens[1]
|
||||||
|
|
||||||
|
print(pos[0] * pos[1])
|
17
02/solve02.py
Normal file
17
02/solve02.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# forward, depth, aim
|
||||||
|
pos=[0,0,0]
|
||||||
|
with open("input01.txt", "r") as f:
|
||||||
|
for line in f:
|
||||||
|
tokens = line.split(" ", 2)
|
||||||
|
tokens[1] = int(tokens[1])
|
||||||
|
if tokens[0] == 'forward':
|
||||||
|
pos[0] += tokens[1]
|
||||||
|
pos[1] += (tokens[1]*pos[2])
|
||||||
|
if tokens[0] == 'up':
|
||||||
|
pos[2] -= tokens[1]
|
||||||
|
if tokens[0] == 'down':
|
||||||
|
pos[2] += tokens[1]
|
||||||
|
|
||||||
|
print(pos[0] * pos[1])
|
Loading…
x
Reference in New Issue
Block a user