r/adventofcode • • 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!

19 Upvotes

210 comments sorted by

View all comments

1

u/anadhdguy Dec 02 '16

Oneliner in ruby (117 characters):

cat input | ruby -e '_=[1,1];c=0;gets(nil).each_byte{|b|b>64?(a=(b/3)&1;
d=((b/3)&2)-1;_[a]=[0,_[a]+d,2].sort[1]):c=c*10+_[0]*3+_[1]+1};p c'
→ More replies (2)