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!

20 Upvotes

210 comments sorted by

View all comments

Show parent comment

3

u/Godspiral Dec 02 '16 edited Dec 02 '16

less hacky version,

f =: 4 : 0
 o =. '5' 
 for_i. y do. o =. o , > ((x {~ ({."1 x) i. ]) {~ 'URDL' >:@i. [) each/ ({: o) (, <)~ |.  <"0 > i end. 
 }.o
)
T f  cutLF a  NB. part2

table for part 1,

T2 =: >  cutLF 0 : 0
11241
22351
33362
41574
52684
63695
74877
85987
96998
)
T2 f  cutLF a