Technology Solutions for Everyday Folks
Screen snip of a portion of the AoC "map" for 2023

Reflections on Advent of Code 2023

I finally gave Advent of Code a shot for 2023! In years past I'd think about/stumble across/remember it a week or two in and automatically 'nope' out of starting. This year, in large part due to the WinAdmins Discord, I was both reminded of it in advance and also had a small community of other folks taking part (and a private leaderboard to watch).

Having never actually participated in Advent of Code (AoC) before, I decided to give it a shot and do so in my "comfort" language PHP. One of the neat things about AoC is that it's designed in such a way that it could be considered language agnostic. Solutions can be developed in a huge array of languages! Rather than try to both learn/stretch into a different language than my daily driver and try AoC, I kept it simple with PHP. That's also important because unlike some other languages I don't have to install/include all sorts of weird libraries...which helps keep the solution pretty "vanilla."

The First Week

The first week (day 1 through 7) was incredibly enjoyable. It was fun to think and work through the problems offered, and it flexed some of my programming muscles in ways that I hadn't been using very often. Most of the week was dealing with processing and calculating based on input strings/data in a fairly "linear" way. Periodically I'd look for inspiration on improving some of the performance, specifically when solutions didn't seem to scale particularly well. In fact, it was only for the part two solution on day 7 that I really needed to look at someone else's solution for an idea of where I'd gone wrong. I had a sorting problem, so while my solution was doing its calculations and other logic correctly, there was an input problem due to how I had been "sorting" the ranked hands with Jokers.

The Second Week

Going into the second week (day 8 through 14) I was on a bit of a tear. But that slowed down a fair bit through the week, a sign of things to come. With two exceptions (day 11 & 12), I was able to solve for the first parts without any/much issue, but the second parts for day 10 and 13 caused me to look for ideas elsewhere. I was "close," but not getting the right results. My day 11 was not a problem with the expanded input (my expansion code worked), but the distance calculations were not working and for part 2 it was simply a scale-related issue (literally multiplied by a billion which did not scale with my original code). Day 12 part one was a stumbler for me on some specific pattern matching; fortunately once I had some working code for part one the second part was pretty straightforward.

During the second week my mindset shifted toward "give it a good try first and if you can't solve/really get stuck try to rework someone else's algorithm and learn something new."

The Third Week

The difficulty level and "creativity" level really started showing during the third week (day 15 through 21). Weirdly, my "best time to a solution" through the entire event was for part one of day 15. I completed the solution within 26 minutes of release (about 10 minutes of effort since I didn't start right at the drop time) and had a global rank of 6,332...actually doing it before I went to bed that night. The remainder of the week, however, was rough. It started working with map-like two-dimensional spaces which was usually fun and interesting, but I had to reference someone else's idea every other day of the week for at least one part of the day's solutions. Much of my issues during the third week could be classified as issues of scale (my solution worked on the test/example data but would not scale/solve in a timely manner for the day's input), issues related to implementing an algorithm (shoelace, area calculation, etc.), a logic typo, or just plain overthinking/over-engineering something and going too far down a weird rabbit hole. By the time the third week came to a close, I was no longer using a majority of my own original work. I was, however, picking up some new bits and learning some interesting things as I reworked other folks' solutions into my own style. This usually manifested by injections of unfamiliar bits (or function calls) which solved for specific points on which I was stuck (e.g. "here's a function that does this specific thing you can't get right"...the results of which I could work with/complete/solve on my own).

During the third week my mindset shifted toward "don't spend a lot of time on a dead end or fixing a scale problem; use someone else's component ideas to fill in the blanks (phone a friend)."

The End Days

With the exception of day 23, days 22 through 25 were a bridge too far for me. Working in three-dimensional spaces and with vectors and whatnot was just too much for me to think around. More specifically, I started stumbling significantly around some of PHP's limitations in this space (other languages are more suited to such things and have better baked-in functionality for sets, vectors, etc.). In fact, because it was the very last problem, I ended up using someone's Python-based implementation for an answer on day 25.

Conceptually, and algorithmically, I understood how to solve for the last few days' worth of problems...especially after working backwards through someone's solution. I just could not translate those concepts to code. In fact, I didn't even bother trying for day 24, part two.

Day 23, on the other hand, was my last "fun" day in AoC 2023. I came up with a solution for part one that was super close to complete; I had even made a neat little function to re-display the "map" at the console so I could see what I was doing/where I was at. But the more I worked on it the more I knew it was going in the wrong direction (my solution would not scale) and that I'd need to implement some sort of algorithm to make it workable with real data. I found a simple depth-first search (DFS) implementation that significantly cut down the tracking of distinct paths (where I was really going off the rails w/r/t scale). Once I had DFS in place, the rest of my code for parts one and two just worked...and worked quickly.

My mindset for the last days boiled down to "see if you can make anything work."

My Final Thoughts for AoC 2023

I'm glad I stuck it out for AoC 2023, even if I ended up "stealing" a lot of solutions toward the end. I spent way too much time on the problems but I definitely picked up some new tricks, learned (or re-learned) some algorithms, and re-discovered where I am not particularly good writing code (and math). I have all of my solutions and my daily notes (where I got stuck and why) in a git repo, but it is private in Github as it includes each day's input. The repo will remain private as the AoC folks don't want input data to be harvestable (I didn't know that when I first created the repo and had already committed several days' worth of solutions) and don't want to scrub the commits. 

My final "stats" for 2023:

  • 48 stars "earned" (of 50)
  • Worst global rank (part one only): 93,436 on day 2
  • Best global rank (part one only): 6.332 on day 15
  • 10 "part 1" hints/inspirations/copies required to solve
  • 10 "part 2" hints/inspirations/copies required to solve
  • 9 days required some form of hint/inspiration/copy (for only one part)
  • 6 days required some form of hint/inspiration/copy (for both parts)

I was fortunate to have time this December to work on these daily problems. Having gone through one year, I definitely intend to participate in future years. Maybe use a different language for different days/solutions, too...we'll see. I recommend giving it a try if you are even remotely interested. Solving for all days is decidedly not required!