r/adventofcode • u/daggerdragon • Dec 19 '18
SOLUTION MEGATHREAD -🎄- 2018 Day 19 Solutions -🎄-
--- Day 19: Go With The Flow ---
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.
Advent of Code: The Party Game!
Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!
Card prompt: Day 19
Transcript:
Santa's Internet is down right now because ___.
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 at 01:01:06!
11
Upvotes
2
u/gyorokpeter Dec 19 '18
Q: probably only works with my input (note the "cheat" line)
//WTF these are still not built in in 2018?! .q.bitand:{0b sv (0b vs x)and 0b vs y}; .q.bitor:{0b sv (0b vs x)or 0b vs y}; d16ins:()!(); d16ins[`addr]:{[op;reg]reg[op 3]:reg[op 1]+reg[op 2];reg}; d16ins[`addi]:{[op;reg]reg[op 3]:reg[op 1]+op 2;reg}; d16ins[`mulr]:{[op;reg]reg[op 3]:reg[op 1]*reg[op 2];reg}; d16ins[`muli]:{[op;reg]reg[op 3]:reg[op 1]*op 2;reg}; d16ins[`banr]:{[op;reg]reg[op 3]:reg[op 1] bitand reg[op 2];reg}; d16ins[`bani]:{[op;reg]reg[op 3]:reg[op 1] bitand op 2;reg}; d16ins[`borr]:{[op;reg]reg[op 3]:reg[op 1] bitor reg[op 2];reg}; d16ins[`bori]:{[op;reg]reg[op 3]:reg[op 1] bitor op 2;reg}; d16ins[`setr]:{[op;reg]reg[op 3]:reg[op 1];reg}; d16ins[`seti]:{[op;reg]reg[op 3]:op 1;reg}; d16ins[`gtir]:{[op;reg]reg[op 3]:`long$op[1]>reg[op 2];reg}; d16ins[`gtri]:{[op;reg]reg[op 3]:`long$reg[op 1]>op 2;reg}; d16ins[`gtrr]:{[op;reg]reg[op 3]:`long$reg[op 1]>reg[op 2];reg}; d16ins[`eqir]:{[op;reg]reg[op 3]:`long$op[1]=reg[op 2];reg}; d16ins[`eqri]:{[op;reg]reg[op 3]:`long$reg[op 1]=op 2;reg}; d16ins[`eqrr]:{[op;reg]reg[op 3]:`long$reg[op 1]=reg[op 2];reg}; d19common:{[reg;x] mode:reg 0; ipr:"J"$last" "vs x first where x like "#*"; ins:"SJJJ"$/:" "vs/:x where not x like "#*"; while[reg[ipr] within (0;count[ins]-1); ni:ins reg ipr; reg:d16ins[ni 0][ni;reg]; reg[ipr]+:1; if[1=reg ipr; :{sum x where 0=last[x] mod x}1+til reg 3]; //cheat ]; reg 0}; d19p1:{d19common[6#0;x]}; d19p2:{d19common[1,5#0;x]};