r/adventofcode • u/daggerdragon • Dec 13 '22
SOLUTION MEGATHREAD -π- 2022 Day 13 Solutions -π-
SUBREDDIT NEWS
Helphas been renamed toHelp/Question.Help - SOLVED!has been renamed toHelp/Question - RESOLVED.If you were having a hard time viewing /r/adventofcode with new.reddit ("Something went wrong. Just don't panic."):
I finally got a reply from the Reddit admins! screenshot
If you're still having issues, use old.reddit.com for now since that's a proven working solution.
THE USUAL REMINDERS
All of our rules, FAQs, resources, etc. are in our community wiki.
A request from Eric: A note on responding to [Help] threads
Signal boost: Reminder 1: unofficial AoC Survey 2022 (closes Dec 22nd)
πΏπ MisTILtoe Elf-ucation π§βπ« is OPEN for submissions!
--- Day 13: Distress Signal ---
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?
6
u/Colin-McMillen Dec 13 '22
C on the Apple //c
The unfun part was parsing strings in C, but that's hardly news for anybody :)
The very fun part was part 2, where stupid me thought "huh ! I'm never gonna be able to load and sort that full dataset in RAM". And what do you do when you can't sort your data in RAM? you external-sort!
I went to the end of that monstruosity even if /u/large-atom kindly pointed out that full sorting was not needed, only counting what goes left and right. And behold, it works. It just takes 25 minutes seeking a 5.25" floppy all around with 21kB of data!
Here's the external-sort version, and the smart version thanks to /u/large-atom. I still prefer the floppy version :)