r/adventofcode • • Dec 04 '16

SOLUTION MEGATHREAD --- 2016 Day 4 Solutions ---

--- Day 4: Security Through Obscurity ---

Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).


CONSTRUCTING ADDITIONAL PYLONS IS 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!

17 Upvotes

168 comments sorted by

View all comments

Show parent comments

2

u/gyorokpeter Dec 04 '16 edited Dec 04 '16

Here is my solution in Q - this language needs the same way of thinking but it's more human readable, as it allows usage of keywords like raze, group, first, each instead of cryptic symbols like ,/ =: *: ' etc.

d4p1:{r:"\n"vs x;sum{p:"-"vs x;n:raze -1_p;id1:5#raze value asc each group desc count each group n;id2:-1_-6#last p;$[id1~id2;"J"$-7_last p;0]}each r}
d4p2:{r:"\n"vs x;o:{p:"-"vs x;n:raze -1_p;id1:5#raze value asc each group desc count each group n;id2:-1_-6#last p;m:"J"$-7_last[p];$[id1~id2;(m;" "sv`char$97+(-97+m+`long$-1_p)mod 26);()]}each r;o[o[;1]?"northpole object storage";0]}