+/AoC

advent of code

git clone https://git.julia.blue/+/AoC

Joseph RyanStart 2018!38c0746

master
457 B19 linesraw
1with open("input.txt") as f:
2    raw = f.read().strip().split(',')
3
4directions = {'n': (1, -1, 0),
5              'nw': (1, 0, -1),
6              'sw': (0, 1, -1),
7              's': (-1, 1,  0),
8              'se': (-1,  0, 1),
9              'ne': (0, -1, 1)}
10
11total = [0, 0, 0]
12distances = []
13
14for i in raw:
15    total = map(sum,zip(total,directions[i]))
16    distances.append(abs(max(total)))
17
18print "Part 1:", distances[-1]
19print "Part 2:", max(distances)