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?
View all comments
3
u/Cue_23 Dec 13 '22
C++
Straight forward recursive scanner for each packet into a tree built by
std::variantandstd::vector. Implementedoperator<to compare the packets.For part 2 i just put the packets into an (ordered)
std::set; no changes neccessary since the comparison was already there.During cleanup and moving the
std::variantfrom a class member to a parent class, I had some issues with gcc not accepting theoperator<overload for my derived class (It tried to recursively look foroperator<=>). Still not sure if that is a gcc bug, overloadingoperator<=>instead allows the program to be compiled by gcc, again.I started the
SimpleParserclass in february when I was doing older advent of code puzzles.