Create a gist now

Instantly share code, notes, and snippets.

@pawlos /advent_of_code_d11.py Secret
Last active Dec 20, 2017

What would you like to do?
Solution to Day 11: Hex Ed - part 1
#aoc_d11.py
pos = (0,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])
#print pos
distance = max(abs(pos[0] - 0),abs(pos[1] - 0))
print distance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment