r/adventofcode • u/daggerdragon • Dec 02 '16
SOLUTION MEGATHREAD --- 2016 Day 2 Solutions ---
--- Day 2: Bathroom Security ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).
BLINKENLIGHTS ARE MANDATORY [?]
Edit: Told you they were mandatory. >_>
This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.
edit: Leaderboard capped, thread unlocked!
20
Upvotes
View all comments
Show parent comment
3
u/John_Earnest Dec 02 '16 edited Dec 02 '16
Nice. I was thinking about the simplification of
2 2&0 0|to2&0|while laying in bed last night, but I hadn't considered trying to make the dictionary definition smaller. Good use of the identity matrix builtin.Any ideas on a smaller representation for part 2's lookup table? We can dispense with 0N and the need to clamp coordinates if we used 0 for invalid cells and wrap the edge of the table with 0 to catch all the boundary conditions:
Edit: several additional golfs for my part 1:
{2&0|x+y}can be replaced with the tacit expression(2&0|+), where+is an ambivalent verb and therefore the train can be applied as dyadic. In both the 'decode' operation3 3/and the initial position of1 1I can get away with using a scalar.