Warning: this post contains spoilers for Advent of Code 2021 Day 3, problem and solutions. Hence, I’m putting everything below the “Read More” tag – continue reading at your own risks.
Continue reading “Advent of Code – Day 3 – Spoilers, lessons and tangents”Tag: advent of code
It’s Advent of Code again!
Yup, for the 7th year in a row: it’s Advent of Code time!
Advent of Code is an advent calendar of programming puzzles. Every day of December until Christmas, you get a new puzzle and a piece of the yearly story in which you need to help the elves save Christmas because Santa is in trouble! In the previous years, we’ve repaired the snow machine, the clock that guides the sleigh, the printer that prints the nice and naughty list, time itself, we brought Santa back from the edge of the Solar System, and we tried to take some vacation last year but it was complicated. It seems this year we need to fetch the keys to the sleigh that got dropped in the ocean by a clumsy elf…
The format of the puzzle is a problem and an input (there’s a number of different inputs, assigned randomly (as far as I can tell) to all the users); the solution (typically a number or a short character string) is what matters to prove that you solved the problem. This means that you can solve it with any language you see fit… or even no language at all. There’s a guarantee that all problems can be solved within 15 seconds on 10-year-old hardware, but it may require some more significant work to get there.
I love Advent of Code. The puzzles are interesting and the difficulty ramp up is usually great, the story is whimsy, and it’s good fun. There’s a competitive aspect to it: there’s a leaderboard for the first 100 people to solve the puzzle, and there’s a “private leaderboard” feature on the website that allows to compete with friends or colleagues. I found it a great way to stretch my coding muscles and practice another language.
This year I decided to solve it in PHP: I’m still learning the language (which I’m now using in my daily professional life), and if previous years are to be believed, I’ll probably learn more than a few tricks – looking forward to that! I’m publishing my (ugly) solutions on GitHub as I go: Balise42/AoC2021.
The first day is easy… who’s in? 🙂
Advent of Code 2019
2019 was the fifth year of Advent of Code – and I consequently spent December waking up at 6AM and spending a lot of brain cycles solving puzzles to bring back Santa from the other side of the solar system, where he was stranded.
Let me quote myself to describe the whole thing to the people who are not familiar with it. Advent of Code is an advent calendar with puzzles that can mostly be solved by programming: the input is a problem description and a user-specific input (as far as I know, there’s a set of a “few” pre-validated/pre-tested inputs), and you have to compute a number or a short string, and provide that as a result. If you have the correct result, you unlock a star and the second part of the puzzle, which allows to unlock a second star. Over the course of the 25 first days of December, you consequently get to collect 50 stars.
When I wrote my Advent of Code 2018 blog post last year, it was December 26th, and I had solved everything – this year it took me until yesterday (so, December 31th) before I got the 50th star. I don’t know if the problems were harder or if I got worse at solving them (maybe a mix of both?), but I still made it before the end of 2019, so I’ll count that as a win 🙂
This year, I worked in Kotlin, a JVM-based language designed by JetBrains, and that I enjoy quite a lot – it is fully compatible with Java, and allows for a much terser syntax, and requires to do things explicitly when it comes to mutability of variables and collections. I like it. My solution repository is on GitHub – beware, here be dragons… and spoilers!
And, like last year, let me give a few impressions of the different puzzles for this year. I WILL spoil the problems and at least hint at their solutions – if you want to start solving the problems with no preconception at all, you may want to stop reading here 🙂
Continue reading “Advent of Code 2019”Advent of Code 2018

In the past few years, December has been for me “the month of Advent of Code”. Advent of Code is an advent calendar with puzzles that can mostly be solved by programming: the input is a problem description and a user-specific input (as far as I know, there’s a set of a “few” pre-validated/pre-tested inputs), and you have to compute a number or a short string, and provide that as a result. If you have the correct result, you unlock a star and the second part of the puzzle, which allows to unlock a second star. Over the course of the 25 first days of December, you consequently get to collect 50 stars.
I like the puzzles, I like the fluff around it (typically a more-or-less-sensical story around the Christmas theme), I like the duration and effort involved, I like that I learn something every year – all in all, I’m a fan 🙂 There’s a “global leaderboard” that tracks all the users who are in the first 100 to solve each puzzle; although I’m on a “favorable” timezone for the puzzles (they come up at 6am for me), I have no hope of ever scoring points on the leaderboard; my claim to fate this year is that I was in the first 1000 players for 11 stars out of 50 🙂
This year, as last year, I solved the whole thing in Go; my Go is still quite bad, probably not-a-all Go-like, and I tend to try to avoid spending too much time second-guessing and refactoring my code in that kind of contexts (it’s good training against analysis paralysis 😉 ), and it’s available on my GitHub if you’re not afraid of bad code and spoilers 🙂 (Oh, and also: truly horrifying code organization.)
After this general introduction, I want to talk a bit about my experience of the individual problems, so beware: spoilers ahead!
Continue reading “Advent of Code 2018”