Hola que tal! While I could write an entry in spanish that would make Cervantes spitful of french people, english is more appropriate. Not only more people speak that language across the world but also if I was to change, I would write in french. Fortunately, I didn’t have to use any of my french while solving today’s puzzle. Time for my Advent of Code 2022 Day 4 cruising log.
One of two things is happening, either my brain is now used to this crazy 4.50 am routine, or today’s problem is easier than yesterday. While it took me a few reads and bugs to get to the solution then, now felt like a breeze.
After reading the problem statement, I caught the essence of the puzzle even though I didn’t have yet the code in mind. Weirdly, this was the first problem so far where I felt like I needed to write proper code. You know, with classes and streams.
Talking about streams, for a moment I fought about recording the coding session but opted not to as I didn’t want to miss the 5 am starting time. OBS will need to wait for another opportunity. However, if you do want to see me write some code in a similar fashing you can open this link.
Since the problem had a sequential flow, using a stream to generate my answer made much sense. I just started writing it from the input to the ultimate output, creating empty methods along the way.
From there, I only needed to fill the gaps which I found pretty straightforward. So straightforward, that this was the fastest I solved and submitted a good answer for part one puzzle this since the first day. Doing so in a record 15 minutes, as opposed to 30 yesterday.
Everything flowed like a melody and the test event passed in the first attempt. As I expected, the second part solution pretty much wrote itself. Just like yesterday, most of the code was there so all I had to do was reuse the code and add a new subroutine to handle this part two puzzle.
Within five minutes, I had yet another test going green and captured the second star of the day. Hopefully, we will keep my puzzle runs as uneventful for the next few days. While I enjoy brain teases, I like them short and sweet.
Now it is still 5.45 am, almost an hour since I got out of bed. I might be able to grab a little bonus sleep before jumping into my morning workout.
Thank you for reading my Advent of Code 2022 Day 4 log, I will see you tomorrow. If you want to check out my previous entry, you can do so there. As usual I will push the code to my repo for this year on Github.
Cover by Vlad Bagacian