-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday2.krk
50 lines (40 loc) · 784 Bytes
/
day2.krk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env kuroko
'''
Template
'''
import fileio
import kuroko
let data
with fileio.open(kuroko.argv[0].replace('.krk','.txt'),'r') as f:
data = f.readlines()
# part 1
'''
let x = 0
let y = 0
for line in data:
let command, dist = line.split()
dist = int(dist)
if command == 'forward':
x += dist
else if command == 'down':
y += dist
else if command == 'up':
y -= dist
print(x,y)
print(x*y)
'''
let pos = 0
let depth = 0
let aim = 0
for line in data:
let command, dist = line.split()
dist = int(dist)
if command == 'forward':
pos += dist
depth += dist * aim
else if command == 'down':
aim += dist
else if command == 'up':
aim -= dist
print(pos,depth)
print(pos*depth)