Skip to content

The Advent of Code 2020 Day 13 log, Thirty-three hours

Posted in Advent of Code

Hello, there and welcome to my Advent of Code 2020 Day 13 cruise log. You may notice that today’s post is much, much later than usual. As it turns out, I did not sleep from yesterday until a few hours ago. Thirty-three sleepless hours. Through a chain of events completely independent from my will, I ended up in a spot where I could not sleep. Actually, I could have gone to sleep at 4 am but chose not to. As a result, a very mushy brain took much longer than I wish to complete today’s challenge. That leaderboard won’t climb itself.

Today’s problem looked inoffensive, and to be fair, it was for the first part. Despite the volatile state of my mind, I managed to craft fairly quickly a solution which passed the example test. All in eighteen minutes and twelve seconds, my fastest part one time since day 6.

My completion times

Part two is where the trouble began. Even though I could feel a strong connection to the first part, the answer kept eluding me. At first, I tried brute-forcing it without any conclusive result. While the tests I created from the further examples passed, the input failed. Brute force would not be any help this time so I guess that it won’t happen for the rest of this season.

You know me, this is where I took out pen and paper, trying to pull my scrambled, tired mind to walk through the algorithm manually. Even then, I could feel myself touching the solution with the tip of my fingers. So close, tests obviously passing, but the cold hard truth of the daily input kept sending me back to a land of failures.

There I went, drawing and drawing. Scheming, calculating, trying to find the right pattern to write my solution from. At times, I could feel my mind drift away, yearning to head towards a warm, comfortable bed. Still, I had to slap myself every once in a while, keep my head in the game. I am certain that some sleep definitely would have helped. Although my changes kept failing once inspected by the input, I could not stop myself from believing the end was near. Over and over, I kept believing the solution to be only a few keystrokes away. Still nothing.

This is where I decided to ask for a hint on the Reddit because there might be a pattern I’m missing or some clever algorithm to solve this. And even before I asked, I found it in there, the Chinese remainder theorem. People kept mentioning it and I do not believe I heard of it before. From there I went on the Wikipedia page thinking that it might be my way out. Then I saw all these mathematical expressions which amounted to Chinese considering the lack of sleep and all that.

This was actually in there, brain said nope so hard

At that point, I closed Wikipedia and took a step back. Almost two hours and a half since I solved the first part and I am stuck. Then I got a realisation, the lowest common multiple which I felt a pull from since the beginning could be used as long as we applied a certain shift. I put the changes together, it looked wildly different from my previous iteration but the tests still passed.

The time comes again, the input will judge my work once more. And it fails, my answer is too high. Like an order of magnitude too high, something is definitely wrong. I can’t quite put my finger on it. Eventually, I spotted that I didn’t skip the values we’re meant to skip according to the problem’s description. After strategically placing another “if” statement, the tests still passed and so did the input.

At last, closure and peace. But now my mind is on fire and I can’t sleep anymore so I go to try and do some Christmas shopping. The cold wind breathing through London freshened my mind and body which eventually led me to return home after a couple of hours. There, finally, I went for a nice hot shower, wrapped myself in a bathrobe and went to bed. Solace. A few hours later, now more recovered but still in need of a few sleep hours, I’m writing this so that I can push this post link alongside the code before working out.

Thank you for reading my Advent of Code 2020 Day 13 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!

Photo by Enikő Tóth from Pexels

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: