r/adventofcode • • Dec 03 '15

SOLUTION MEGATHREAD --- Day 3 Solutions ---

--- Day 3: Perfectly Spherical Houses in a Vacuum ---

Post your solution as a comment. Structure your post like the Day One thread in /r/programming.

24 Upvotes

228 comments sorted by

View all comments

Show parent comment

1

u/stuque Dec 03 '15

next_house could instead be written like this:

moves = {'<': (-1, 0), 
         '>': (1, 0),
         '^': (0, 1),
         'v': (0, -1),
        }

def next_house(loc, d): return map(sum, zip(loc, moves[d]))