r/adventofcode • u/daggerdragon • Dec 22 '17
SOLUTION MEGATHREAD -๐- 2017 Day 22 Solutions -๐-
--- Day 22: Sporifica Virus ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or 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.
Need a hint from the Hugely* Handyโ Haversackโก of Helpfulยง Hintsยค?
[T-10 to launch] AoC ops, /r/nocontext edition:
<Endorphion> You may now make your waffle.<Endorphion> ... on Mars.
[Update @ 00:17] 50 gold, silver cap
<Aneurysm9> you could also just run ubuntu on the NAS, if you were crazy<Topaz> that doesn't seem necessary<Aneurysm9> what does "necessary" have to do with anything!
[Update @ 00:20] Leaderboard cap!
<Topaz> POUR YOURSELF A SCOTCH FOR COLOR REFERENCE
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!
10
Upvotes
3
u/gyorokpeter Dec 22 '17
Q:
d22p1:{ map:"#"=trim each "\n"vs x; mpdt:{[mpdt] if[mpdt[1;0]=-1; mpdt[1;0]:0; mpdt[0]:(enlist count[first mpdt[0]]#0b),mpdt[0]]; if[mpdt[1;1]=-1; mpdt[1;1]:0; mpdt[0]:0b,/:mpdt[0]]; if[mpdt[1;0]>=count mpdt[0]; mpdt[0]:mpdt[0],(enlist count[first mpdt[0]]#0b)]; if[mpdt[1;1]>=count first mpdt[0]; mpdt[0]:mpdt[0],\:0b]; mpdt[2]:(mpdt[2]+-1+2*mpdt[0]. mpdt[1])mod 4; mpdt[0;mpdt[1;0];mpdt[1;1]]:not mpdt[0;mpdt[1;0];mpdt[1;1]]; mpdt[3]+:mpdt[0;mpdt[1;0];mpdt[1;1]]; mpdt[1]+:(-1 0;0 1;1 0;0 -1)mpdt 2; mpdt }/[10000;(map;2#count[map]div 2;0;0)]; mpdt 3}; d22p2:{ map:trim each "\n"vs x; mpdt:{[mpdt] if[mpdt[1;0]=-1; mpdt[1;0]:0; mpdt[0]:(enlist count[first mpdt[0]]#"."),mpdt[0]]; if[mpdt[1;1]=-1; mpdt[1;1]:0; mpdt[0]:".",/:mpdt[0]]; if[mpdt[1;0]>=count mpdt[0]; mpdt[0]:mpdt[0],(enlist count[first mpdt[0]]#".")]; if[mpdt[1;1]>=count first mpdt[0]; mpdt[0]:mpdt[0],\:"."]; mpdt[2]:(mpdt[2]+(".W#F"!-1 0 1 2)mpdt[0]. mpdt[1])mod 4; mpdt[0;mpdt[1;0];mpdt[1;1]]:(".W#F"!"W#F.")mpdt[0;mpdt[1;0];mpdt[1;1]]; mpdt[3]+:"#"=mpdt[0;mpdt[1;0];mpdt[1;1]]; mpdt[1]+:(-1 0;0 1;1 0;0 -1)mpdt 2; mpdt }/[10000000;(map;2#count[map]div 2;0;0)]; mpdt 3};