46
SOLUTION MEGATHREAD-🎄- 2021 Day 16 Solutions -🎄-(self.adventofcode)
submitted 4 years, 1 month ago* (edited 27 minutes after) by daggerdragon to /r/adventofcode (134.8k)
NEW AND NOTEWORTHY
DO NOT POST SPOILERS IN THREAD TITLES!
- The only exception is for `Help...
4 years ago
—
4 years, 1 month ago4 of 4
Tip Reveddit Real-Time can notify you when your content is removed.
your account history
Tip Check if your account has any removed comments.
view my removed comments you are viewing a single comment's thread.
view all comments


Python 3. Compact/readable/fast.
The whole "literal padding" thing caused loads of confusion. Once I realised it is a problem to be ignored, it's recursion to the rescue again (full code here). Code is short (1 line I/O and readable 27-line parse function with comments).
Returning the index for the next subpacket with the value of the current subpacket really simplifies things.
You are so smart! Thanks for posting this! I was so stuck on how to do recursion on this. It turns out using the start index is the way to go! Thanks!
It started out much clunkier - with two types of counters in the arguments to the parse function. But I thought best to post the prettier, cleaner version :). Thanks for the compliment :)
This worked! Thx!