r/adventofcode • u/daggerdragon • Dec 18 '21
SOLUTION MEGATHREAD -🎄- 2021 Day 18 Solutions -🎄-
NEW AND NOTEWORTHY
- From /u/jeroenheijmans: Reminder: unofficial Advent of Code survey 2021 (closes Dec 22nd)
- FYI: 23:59 Amsterdam time zone is 17:59 EST
Advent of Code 2021: Adventure Time!
- 5 days left to submit your adventures!
- Full details and rules are in the submissions megathread: 🎄 AoC 2021 🎄 [Adventure Time!]
--- Day 18: Snailfish ---
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.
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:43:50, megathread unlocked!
46
Upvotes
View all comments
Show parent comment
3
u/damaltor1 Dec 18 '21
I think you are right.
The solving for the magnitude still is the same though: starting left, search for the first two numbers with the same depth (
xandywith the depthd), calculate the magnitudemas3x+2y, remove both from the list and insert a new number with the valuemand the depthd-1. then start over from the left end of the whole list, until there is only one number left.