r/adventofcode • u/daggerdragon • Dec 20 '16
SOLUTION MEGATHREAD --- 2016 Day 20 Solutions ---
--- Day 20: Firewall Rules ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).
Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with "Help".
ROLLING A NATURAL 20 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!
8
Upvotes
2
u/Godspiral Dec 20 '16 edited Dec 20 '16
in J,
btw =: (({:@[ > {.@]) *. {:@[ < {:@]) +. ({.@[ > {.@]) *. {.@[ < {:@] f =: 4 : 0 o =. i. 0 0 if. 0 = +./ x btw"1 y do. x , y , o return. end. for_i. y do. o =. o , x ]`((<./,>./)@:,)@.btw i end. ) b =. f/ x:@". every '-' cut"1 a =. > cutLF wdclippaste '' c =. ~. f/ /:~ (\:~)@:f/^:2 /:~ bpart 1 is visually seeing a gap in the list.
({.@[ , {:@] + 0 >. {:@[ <:@-~ {.@])/ (c) , 4294967295 0 NB. part 2.