tohuwabohu In technology, chaos reigns supreme.

Advent of Code 2023


Starting tomorrow, the Advent of Code will again provide a set of challenging puzzles by Eric Wastl. Last year, I held the line until December, 15th, when I had do bow out as those puzzles become more time-consuming the further you get. Generally speaking, I see the Advent of Code as a great opportunity to dive into a programming language you’re not familiar with. In 2022, I chose kotlin mainly because I heard many positive things about it. Also, it was an obvious next step as I’ve been a Java developer since forever.

Lately, I got into an argument with somebody who mentioned that the AoC is a bad opportunity when trying to learn something new. I usually try to be open about other opinions, but this time I had to plainly disagree. Hard.

What are your goals?

When learning something new, you have to ask yourself: What exactly are you trying to achieve? It is perfectly fine to learn something you likely won’t be using in the future just for the sake of learning something new. As a matter of fact, according to the UNESCO, learning physically strengthens your brain. This can be any skill from juggling to playing the trombone; including solving software puzzles.

If you aim for learning a new programming language, you will have touch-points with its fundamentals. Every puzzle essentially boils down to processing a file or an input string, applying an algorithm of some sort and printing the result in any way. Your only constraint is that the result should be human-readable because you will need to enter the value on the AoC puzzle page. You basically build your own black box.

Maybe you are trying to strengthen your familiarity with a programming language that you are using on a daily basis. Then, the AoC is a great opportunity to set up your own utility package where you can collect things like file processing or homebrew implementations of algorithms. You could also use libraries you always wanted to try or maybe language features you were unaware of. Those are things that you can use for the next years AoC as well. Some people even build their own graphical result visualization tools.

Later on, those puzzles usually contain number theory, directed graphs and other challenges requiring you to identify and choose the right algorithm to solve the problem. Improving this skill could be your goal as well!

You don’t need to finish

As opposed to the real world, you will not have a time constraint - except if your goal is to finish on top of the leaderboard. Depending on your goal, it is perfectly fine to skip a few days. Personally, last year, the first 10 - 12 days provided enough challenge for me to cover the basics. On day 14, I produced a piece of kotlin code that I’m still very proud of.

private val adjacent = listOf(
    Point(0, 1), // straight down
    Point(-1, 1), // down left
    Point(1, 1) // down right
)

private fun trickle(
    matrix: Array<Array<Tile>>, 
    startY: Int, 
    startX: Int, 
    tracker: Tracker
): Boolean {
    if (tracker.overflow) return true

    adjacent.forEach { point ->
        val search = Point(startX + point.x, startY + point.y)

        if (search.y in matrix.indices && search.x in matrix[0].indices) {
            if (matrix[search.y][search.x].reservoir == '.') {
                trickle(matrix, search.y, search.x, tracker)
            }
        } else {
            tracker.overflow = true
        }
    }

    if (!tracker.overflow) {
        tracker.counter++
        matrix[startY][startX].reservoir = 'o'
    }

    return true
}

So, you could just wait for a suitable puzzle and exclusively focus on that one. Nobody will judge you.

Helpful community

Given the fact that each puzzle has specific input while expecting a specific solution, the verification process happens instantly. Nobody is required to manually review your result. However, if you struggle during your implementation process, people are usually happy to help in a constructive-minded way. The main hub for this is usually the r/AdventOfCode subreddit. Depending on your chosen programming language, own sections exist within forums or community servers, like on the Elixir forum. JetBrains even provided sample implementations in idiomatic kotlin for some days.

This year, Scala will be my weapon of choice. I fully expect to last until mid of December at most, like last year. I plan to strengthen my familiarity with functional languages and I think Scala offers that for developers that come from a paradigm dominated by OOP and, in my opinion, it is a good idea to expand your mind and see how the same results can be accomplished with a different approach.

What do I expect from learning Scala? I have no clue. But, after getting familiar with kotlin last year, I began implementing a Fullstack hobby project with it. So, who knows what happens?

See you on the leaderboard!

Tagged as: aoc opinion