r/adventofcode • u/daggerdragon • Dec 20 '22
SOLUTION MEGATHREAD -π- 2022 Day 20 Solutions -π-
THE USUAL REMINDERS
All of our rules, FAQs, resources, etc. are in our community wiki.
πΏπ MisTILtoe Elf-ucation π§βπ« is OPEN for submissions!
3 DAYS remaining until submission deadline on December 22 at 23:59 EST
UPDATES
[Update @ 00:15:41]: SILVER CAP, GOLD 37
Some of these Elves need to go back to Security 101... is anyone still teaching about
Loose Lips Sink Shipsanymore? :(
--- Day 20: Grove Positioning System ---
Post your code solution in this megathread.
Read the full posting rules in our community wiki before you post!
Include what language(s) your solution uses
Format code blocks using the four-spaces Markdown syntax!
Quick link to Topaz's
pasteif you need it for longer code blocks. What is Topaz'spastetool?
This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.
EDIT: Global leaderboard gold cap reached at 00:21:14, megathread unlocked!
23
Upvotes
4
u/Colin-McMillen Dec 20 '22 edited Dec 21 '22
C on the Apple //c
First version: Well. I suck at doubly-linked lists so I shift one position at a time. This is quite a number of CPU cycles, but it's going to be quite a number of cycles anyway so let's leave it at that and spend the evening doing something else!
Second version: it finished overnight but I was unhappy with it, so I optimized (pluck, shift all the way, put back ; modulo 5000 to avoid doing one loop and a half; and go the other way if shift > 2500) and runtime is now 13 minutes (for part 1).
Managed to put the doubly-linked list with an extra pointer for original order in RAM, using a system loader in order to unload ProDOS to get all of 45kB free.