r/adventofcode • u/daggerdragon • Dec 16 '18
SOLUTION MEGATHREAD -🎄- 2018 Day 16 Solutions -🎄-
--- Day 16: Chronal Classification ---
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 16
Transcript:
The secret technique to beat today's puzzles is ___.
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 00:39:03!
16
Upvotes
View all comments
Show parent comment
3
u/phil_g Dec 16 '18
Nice. I took a similar approach in my Common Lisp solution.
I like your syntax for immediate values; it's less clunky than my
:immediatekeyword arguments. I reduced my repetitive typing a little by writing a couple extra macros for instructions that mapped directly to Common Lisp functions (which was everything exceptsetrandseti).I chose to use a dynamic variable to hold the registers with a macro to wrap uses of a common set of registers. I debated a bit whether that was a better approach than passing the registers in and out of the instruction functions. Obviously the latter is more functional, but since we're modeling an imperative CPU I went with the more imperative approach. Either works, of course.