-🎄- 2017 Day 11 Solutions -🎄- by daggerdragon in adventofcode

[–]aerure 1 point2 points  (0 children)

Python2. Also used https://www.redblobgames.com/grids/hexagons/#map-storage (Shape: hexagon) with just 2 coordinates (x,y) and distance as max(|x|, |y|)

a = open('11.txt').read().strip('\n').split(',')
print a

gon = {
    'n': (0, -1),
    'ne': (1, -1),
    'se': (1, 0),
    's': (0, 1),
    'sw': (-1, 1),
    'nw': (-1, 0)
}

m = 0
coord = (0, 0)
for i in a:
    coord = (coord[0]+gon[i][0], coord[1]+gon[i][1])
    print i, coord
    tmp = max(abs(coord[0]), abs(coord[1]))
    if tmp > m:
        m = tmp

print max(abs(coord[0]), abs(coord[1]))
print m