-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution.py
42 lines (31 loc) · 829 Bytes
/
solution.py
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
input = open('data.txt', 'r').read().split(",")
coords = {"x": 0, "y": 0, "z": 0}
dist = []
for c in input:
if c=="n":
coords["x"] += 0
coords["y"] += 1
coords["z"] += -1
if c=="ne":
coords["x"] += 1
coords["y"] += 0
coords["z"] += -1
if c=="se":
coords["x"] += 1
coords["y"] += -1
coords["z"] += 0
if c=="s":
coords["x"] += 0
coords["y"] += -1
coords["z"] += 1
if c=="sw":
coords["x"] += -1
coords["y"] += 0
coords["z"] += 1
if c=="nw":
coords["x"] += -1
coords["y"] += 1
coords["z"] += 0
dist.append( ( abs(-coords["x"]) + abs(-coords["y"]) + abs(-coords["z"]) )/2 )
print("First part: " + str(dist[-1]))
print("Second part: " + str(max(dist)))