Skip to content

The Advent of Code 2022 Day 21: Monkey maths

Posted in Advent of Code

Hello everyone, long time no post. I’ve had quite a hectic few days but finally, I managed to take on a puzzle on its release day. Sure I had to do the first part at lunchtime and the second after work but we’re getting there. Welcome to my Advent of Code 2022 Day 21 cruise log.

Last night after watching Guillermo del Toro’s Pinocchio with my fiancee, we got to bed at a fair time. As a matter of fact, she had to catch an early flight to Italy to join her family for Christmas. The side effect of that is my waking up at 4 am which felt way too early so after kissing goodbye I went back to sleep.

Big mistake! I ended up opening my eyes at about 9.20 am, way too late to take on today’s puzzle. However, it is right on time to begin work which I did right away. Surely the day can allow me to tackle the puzzle through lunchtime. Except that no fiancee at home means I need to cook my own lunch. Basically, half the break went into that but I still had about half an hour to read the problem and code a bit.

Fortunately, twenty minutes were all I needed to scrape through and take on that first star of the day. Time to return to work. Fast-forward a few hours, I turn off my professional laptop and switch on the gaming one. Now we can look at part two. And what a part it was. While I grasped fairly quickly what I needed to do, I still struggled to translate it into code.

After about an hour of writing and drawing away, I finally figured out the way. Well, almost, I still made some adjustments along that way but eventually got a positive result. My code passed the validation test. Unfortunately, it failed against the real input. Back to the metaphorical drawing board.

After another thirty minutes, I spotted the edge case I was missing while debugging the real input. I don’t want to spoil people taking on this so I won’t say what it was but I felt quite stupid when I saw it. Classic maths! From there I wrote two small tests to confirm this theory and they both failed. From there I wrote the fix, the tests passed and I was finally able to capture my final star of the day.

Well, final star if I don’t try to catch up by taking on days 16, 17, 18, 19 and 20. I’m gonna take a break but I might try to take on another puzzle or two later tonight. Wish me luck.

Thank you for reading my Advent of Code 2022 Day 21 log, I will see you eventually. If you want to check out my previous entry, you can do so here. You can even read my entries from last year there. As usual, I will push the code to my repo for this year on Github. Also, if you want to test yourself against my AoC 2022 run, I’ve created a private leaderboard. The invite code is 382952-d065ee7a . Join, if you dare.

Cover by Nitin Dhumal

Be First to Comment

    Leave a Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    %d bloggers like this: