Advent of Code in Kotlin : Learnings day by day.

The thread of all my solutions, day after day on how I solved Advent of Code puzzles in Kotlin! Every day I record myself, and then revisit and improve my solution to learn from them.

Advent of Code in Kotlin : Learnings day by day.

TL;DR : The repository with all solutions, before and after I revisit them. List of solutions at the end of this post

Hi everyone!

I am not sure how many of you know about Advent of Code but it's a really fun programming competition that takes place every year in December. I like it a lot, not so much for the competitiveness, but because of the variety of challenges and the quick ramp up in difficulty.

I have tried to live stream my attempts in the past but I know that after a few days life comes in the way so I've decided to try something new this year!

  • I'll record myself as I do the challenges. Even if it takes several sessions
  • I'll time myself and post the quick and dirty first version of the code
  • And then I'll come back with a better version and share what I've learnt from it!

Why do I think this, I hear? For a few reasons:

  • to force myself to go back to the challenges. I usually stop after I have the dirtiest solution. This will help me learn things.
  • So you can learn too. If I learn, maybe you get a fast track to discovering something new too :).
  • To show that even seniors struggle, google stuff! I have 10 years experience, and I google and stumble on the simplest things. And honestly, that's ok :).

Hopefully you can learn some things too! Let's see how long I can keep this going :). Most of my solutions will be in Kotlin!

Don't expect the best solution out there here, I'm not checking what others are doing. If you want the best, I suggest you check the SubReddit.

So, here goes nothing!

The repository with all solutions, before and after I revisit them (final solutions are in the final package).

Solutions entries :

  • Day 1 : zip, and basic OBS tricks
  • Day 2 : regex destructuring!
  • Day 3 : drop, take and filterIndexed
  • Day 4 : require in data classes and flatMapIndexed
  • Day 5 : binary representations and data classes val init

Hope you like it! Don't hesitate to reach out on Twitter if you want to raise issues or ask questions :).

See you tomorrow for day 1!

Note : Even though I am still planning on finishing the sessions, a few things have made it hard for me to continue past the first few days of the event : I got a second daughter (🥳🥳🥳), Maela during the month of December :). The second thing is that the lockdown has been strengthened and schools have closed, meaning that I cannot record anything without having 2 kids in the background and that makes it exhausting. I hope to be back to it soon!