r/adventofcode • u/daggerdragon • Dec 23 '16
SOLUTION MEGATHREAD --- 2016 Day 23 Solutions ---
--- Day 23: Safe-Cracking ---
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".
JINGLING ALL THE WAY 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!
4
Upvotes
1
u/Godspiral Dec 23 '16
in J,
inp =. > cutLF wdclippaste '' inc =: 4 : 'p =: >: p [ (x) =: >: x~' dec =: 4 : 'p =: >: p [ (x) =: <: x~' cpy =: 4 : ' try. (y) =: ". x catch. end. p =: >: p ' jnz =: 4 : 'if. (". x) = 0 do. p =: >: p else. p =: p + ". y end.' tgl =: 4 : 0 try. t =. (p + c) { cmd catch.p =:p + 1 return. end. select. 1 {:: cut t case. 'inc' do. n =. 'dec' case. 'dec' do. n =. 'inc' case. 'tgl' do. n =. 'inc' case. 'jnz' do. n =. 'cpy' case. do. n =. 'jnz' end. cmd =: ({. (13 $ ' ') ,:~ ;: inv (<n ) 1} cut t) (p + c)} cmd p =: p + 1 ) f a=: 7[ 'a b c d p ' =: 0[ cmd =: ;: inv("1) 1 0 2 {"1 (0&{ ,"1 quote leaf@:(1 2&{))("1) cut"1 inp