Hello, there and welcome to my Advent of Code 2020 Day 10 cruise log. While I don’t believe today’s challenge was particularly difficult, it did give me a hard time. All my fault. As days progress, these things will happen. I will make stupid mistakes. Mistakes that will remind me that I am no Brainiac. Let’s start with the beginning, shall we?
Unlike some other times, I actually parsed the problem relatively correctly. As it turns out I implemented the first part right. Well, my tests failed but only because I forgot to add two discrete values to the input to reflect the subject. No big deal as it took only a couple of minutes away from me. I was exactly off by one on the counts for the main two distributed values. It got me to read the subject again and notice that I forgot the max value appendix and the starting point value which are not part of the input. Once I got that right, my tests passed and I ran my input to claim the first star of the day.
Now for the second part, this is where the pain begins. At first, I put together a completely nonsensical algorithm. I tried to code first, code fast and failed miserably. From there, I took a second back and decided to draw what the algorithm would look like to have a better picture of it. In order to do so, I used the first and shortest example provided. Within five minutes I guess, I reproduced the algorithm threw drawing a graph.
Once the drawing complete, my issue became obvious. As it turns out, my quickly put together solution wasn’t that far off. I only needed a tiny change to make it work, make it right. After my change, I ran my small sample test again. It passed. Feeling like the power of Thor flowing through me I run the test with the larger sample and it failed. At this point I’m flabbergasted, the algorithm is perfect. Well, to the extent that it should be working and yet here we are. The big test failed. And this second star that felt so close once is now far away.
I tried mentally debugging the larger set as if it’d work. Looking through lore to figure which virgin I need to sacrifice so that my larger input test work. Nothing. I ran the test over and over and over with no change while hoping for a different result. Some would call that insanity. Maybe that was the tipping point. Maybe software development isn’t for me after all. I could sell the house, get out of London with my guitar and play in the streets. I have no skill, no brain, nothing left to offer while despair is creeping in for that my career end is nigh.
In spite of the rising madness, a desperate attempt to safeguard my sanity and career, I rerun the tests again. Nothing still, I go through the tests again. They seem correct. Oh, wait, no, they don’t. Not all of them. The larger input test for today’s second part is calling the method from the first part. Running the test again. And it passed. Running today’s input and it grants me the final star of the day. I can’t believe I just wasted a half-hour of my life doubting myself but now eventually prevailed. Let’s put this all behind us and never mention it ever again, deal? Deal.
Thank you for reading my Advent of Code 2020 Day 10 cruise log, I will see you tomorrow, maybe. In the meantime, you can check out my Go Cloud series about building and deploying a Golang app to AWS. Also, I will push my code on Github at CodingNagger/advent-of-code-2020 so feel free to check it out but not before you’ve done the challenge yourself. Bye!