Hello, there and welcome to my Advent of Code 2020 Day 12 cruise log. Today felt much better than yesterday. That headache mentioned in the previous post set sails out of my head after a very enjoyable evening. Quite frankly, I’m surprised that I still managed to wake up just before 5 am. I threw some cold water at my face, unbeknownst to me, it would be the theme of today’s challenge. While the first part was plain sailing, the second made some waves, let’s jump into it.
The problem starts with the lore as usual, for some reason we’re on a boat now. I guess that changes scenery from the previous years either in the North pole or Spaaaaaaaaace. Here, our input is a set of instructions which we need to parse in order to determine where we’re moving the boat towards. After a good half-hour kinda chilling and coding, I got by boat struct with some methods that passed the example test. We’re on the right track so far so I execute my input against the code and it gives me my first star. Hunky-Dory!
As I am on a roll, I start reading the second part description and my brain has a hard time parsing it. We’re not moving the boat but there’s a made-up point on the map move to the boat towards. Also, the transformations we applied on the boat in part one are applied on that made-up point instead. Believe me, it’s a tad more treacherous than it sounds. Even though I felt a bit lost, I started putting some code together. Mostly, I relied on what I did in the previous part and while it wasn’t a terrible strategy it failed. My part two test failed and I already spent about forty minutes on it.
The clock was ticking, the tide was rising and I need to make a change. Then I lit up, “He’s a pirate” starts playing in my head. “Prepare every vessel that floats, we’re now at war!” I scream internally to my sailor-shaped brain cells. They start moving, buzzing around, and I decide to make a bold move. Rewrite the whole part two code, ballsy but it will cost me. I will need to make up the leeway by firing these neurons at full power. After twenty minutes in the zone, I came out the other way with a completely different implementation.
My test fails, again, with exactly the same result. However, this time, the implementation allowed me to spot something I didn’t with the original implementation. The waypoint rotation is opposite to the boat. So I switched my left and right rotation methods for the waypoint and it worked! From there I’m ready to dunk on the sirens by running my input through my new needlessly rewritten code and capture the final star of the day. The crowd went wild because for some reason we’re in a stadium now.
Thank you for reading my Advent of Code 2020 Day 12 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!