Skip to content

Instantly share code, notes, and snippets.

@pawlos
Last active December 20, 2017 14:12
Show Gist options
  • Save pawlos/f013e298c150d0b07370d0bdfff4fe0f to your computer and use it in GitHub Desktop.
Save pawlos/f013e298c150d0b07370d0bdfff4fe0f to your computer and use it in GitHub Desktop.
Solution to Day 11: Hex Ed - Part 2
#aoc_d11.py
pos = (0,0)
max_dist = 0
inp = open('input_d11.txt','r').read().split(',')#["ne","ne","s","s"]
dic = {"ne": lambda x,y: (x+1,y+1), "n": lambda x,y: (x,y+1), "nw": lambda x,y: (x-1,y+1),
"w": lambda x,y: (x-1,y),
"e": lambda x,y: (x+1,y),
"se": lambda x,y: (x+1,y-1), "s": lambda x,y: (x,y-1), "sw": lambda x,y: (x-1,y-1),}
for i in inp:
pos = dic[i](pos[0],pos[1])
distance = max(abs(pos[0] - 0),abs(pos[1] - 0))
if distance > max_dist:
max_dist = distance
#print pos
distance = max(abs(pos[0] - 0),abs(pos[1] - 0))
print distance, max_dist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment