-
Notifications
You must be signed in to change notification settings - Fork 0
/
day11.py
43 lines (32 loc) · 834 Bytes
/
day11.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
43
# https://www.redblobgames.com/grids/hexagons/ for inspiration
with open('day11-input.txt') as f:
child_path = f.readline().strip().split(',')
# cube coordinates
x = 0
y = 0
z = 0
max_distance = 0
for step in child_path:
if step == 's':
y -= 1
z += 1
if step == 'se':
x += 1
y -= 1
if step == 'sw':
x -= 1
z += 1
if step == 'n':
y += 1
z -= 1
if step == 'ne':
x += 1
z -= 1
if step == 'nw':
x -= 1
y += 1
distance = int((abs(x) + abs(y) + abs(z)) / 2)
if distance > max_distance :
max_distance = distance
print(int((abs(x) + abs(y) + abs(z)) / 2))
print(max_distance)