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!
8
Upvotes
View all comments
Show parent comment
4
u/Smylers Dec 22 '17 edited Dec 24 '17
Explanation of how
@aperforms one burst. At the start of a burst, both the cursor and the mark ```m`` is on the current node.~— Capitalize the current node, so it's distinct from the others (that's why the punctuation were replaced by letters).:/O/norm…performs the specified keystrokes on the next line with anOon it. There will be either one or zero such lines, so this logic effectively becomes ‘If the current node is clear then ...’. The:silent!makes it avoid ending the surrounding macro in the case that it doesn't match. The:sil!/X/norm…is likewise for the ‘current node is infected’ case.:normalkeystrokes begin with⟨Ctrl+W⟩pto switch to the status window, then manipulate the bottom line, withkljhon it. The leftmost character indicates the way we're facing by means of the absolute direction most recently travelled in (initiallyk, for facing upwards). On a clear node,}x0Pmoves the last character on the line to the beginning; on an infected node,Gx$pmoves the first character to the end — in either case, the first character on the line is now the next absolute direction to move in.k⟨Ctrl+A⟩also increases the infection count, the number at the top of that window.rto update the node to its new state. This is always in lower-case, so anOthat's been converted to anxin the first rule doesn't then trigger the second rule for converting anXinto ano.Gyl, switch back to the main window and move in that direction with:norm ⟨Ctrl+R⟩0, effectively ‘pressing’ the direction as a keystroke. Thenmmto set this as the current position for next time through.:/…/commands (more than doubling the length of the macro) are for extending the grid: each checks if the cursor has reached an edge, and if so adds another line/column ofos to that edge. Each are protected by:silent!so they don't complain if they don't match./%\'m%1l/to match if the ```m`` mark is in the top row./%\'m.*\n.@!/— specifically if after mark ```m`` and the rest of that line, there isn't another character.roto convert all the characters in it to clear nodes.Edit: Mark formatting improved, thanks to /u/obiwan90.