Day 25: Full of Hot Air

I’m not sure why he didn’t call this one SNAFU, but it was easy and fun, which I think is typical on Day 25.

Anyone add up the numbers using SNAFU arithmetic, or did everyone convert to decimal, add, then convert back?

PS If I may be allowed a personal remark: This is my third time doing AoC, but the first one I’ve completed it in time: for the 2020 competition I finished up around New Year’s instead of Christmas Day; then I went back and completed the 2019 competition, and then I took a break until this year. Having thsi forum to discuss things with, even to vent frustration once or twice, was helpful. I really enjoyed learning from everyone. Maybe I’ll go back and complete some other years… after getting some :sleeping_bed: first. :grin:

4 Likes

I think everyone converts to some integer type (regardless of the internal representation) and back to SNAFU. But it must be fun to do SNAFU arithmetic directly. Perhaps an idea for smoothing the post-AoC syndrome :wink:.

2 Likes

I did conversion first, but now implemented Snafu-Arithmetic for addition: aoc2022-Ada/day25.adb at main - aoc2022-Ada - Codeberg.org

As data type, I use a 25-element array of Snafu digits, which are a simple subtype of Integer in the range -2 .. 2.

2 Likes

This one was easy and fun. Like others, I just converted to and from decimal. I was able to do it over breakfast this morning, but then family activities intervened for most of the day so it wasn’t until dinner time that I was able to get it to pass gnatprove. The mathy ones have been the biggest pain with the various range checks.

It has been great fun having a group of people like this to discuss the problems with! I have also really gotten to like Ada and SPARK and I plan to continue using them!

4 Likes