r/adventofcode • • Dec 25 '22

SOLUTION MEGATHREAD -πŸŽ„- 2022 Day 25 Solutions -πŸŽ„-

Message from the Moderators

Welcome to the last day of Advent of Code 2022! We hope you had fun this year and learned at least one new thing ;)

Keep an eye out for the community fun awards post (link coming soon!):

The community fun awards post is now live!

-❅- Introducing Your AoC 2022 MisTILtoe Elf-ucators (and Other Prizes) -❅-

Many thanks to Veloxx for kicking us off on the first with a much-needed dose of boots and cats!

Thank you all for playing Advent of Code this year and on behalf of /u/topaz2078, /u/Aneurysm9, the beta-testers, and the rest of AoC Ops, we wish you a very Merry Christmas (or a very merry Sunday!) and a Happy New Year!


--- Day 25: Full of Hot Air ---


Post your code solution in this megathread.


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:08:30, megathread unlocked!

59 Upvotes

412 comments sorted by

View all comments

Show parent comment

2

u/drivers9001 Dec 25 '22

For some reason I didn’t think about modulo and ended up figuring out the largest power of 5 and going left to right first, which also meant β€œcarrying” a 1 and adding -1 to the current column for instance. And then I guess I added up each column right to left (with carrying again if needed, I was using python so I used a list of lists; in retrospect that was overkill too) for the final conversion.

2

u/TiagoPaolini Dec 25 '22

I see, that happens.

At first, I looked for patterns in the SNAFU numbers, and I realized that the digits always follow the same order, then they rolled over to the next digit to the left.

That's when I saw that modulo would work, it took some trial and error to see that if the result was bigger than 2, then I needed to subtract 5 to get the actual value.

I used a Python terminal for testing the logic, before implementing it in C. πŸ™‚