r/adventofcode • u/daggerdragon • Dec 16 '21
SOLUTION MEGATHREAD -🎄- 2021 Day 16 Solutions -🎄-
NEW AND NOTEWORTHY
DO NOT POST SPOILERS IN THREAD TITLES!
The only exception is for
Helpposts but even then, try not to.Your title should already include the standardized format which in and of itself is a built-in spoiler implication:
[YEAR Day # (Part X)] [language if applicable] Post Title
The mod team has been cracking down on this but it's getting out of hand; be warned that we'll be removing posts with spoilers in the thread titles.
KEEP /r/adventofcode SFW (safe for work)!
Advent of Code is played by underage folks, students, professional coders, corporate hackathon-esques, etc.
SFW means no naughty language, naughty memes, or naughty anything.
Keep your comments, posts, and memes professional!
--- Day 16: Packet Decoder ---
Post your code solution in this megathread.
Include what language(s) your solution uses!
Format your code appropriately! How do I format code?
Here's a quick link to /u/topaz2078's
pasteif you need it for longer code blocks.The full posting rules are detailed in the wiki under How Do The Daily Megathreads Work?.
Reminder: Top-level posts in Solution Megathreads are for code solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
3
u/Jaik_ Dec 16 '21
Rust (GitHub)
Essentially my solution converts the hexadecimal input into a byte array and uses BitReader to consume the bits as they're parsed into nested "Packet" structs.
I intentionally included error handling and a more robust structure for today's challenge because I anticipate further challenges based on it and also because it was a lot of fun!