Advent Of Code 2026 - Day 1

An elf wearing a green and yellow Christmas hat standing in front of a pile of crates.

I’ve attempted to do Advent of Code a couple of times in the past, but I usually give up after day 5 or 6, when it starts to take too much of my time. I completely ignored last year, so my brain is craving some self punishment.

Here is my solution to day 1’s puzzle. I’ve decided to go with Kotlin (in the past, I used Swift) because IntelliJ was open. I think trying to learn a new language at the same time would have been asking for trouble.

// 1. Load puzzle input into a Sequence<String>
// 2. Group by value
// 3. Turn into a list of <Int, Int> tuple
// https://kotlinlang.org/docs/sequences.html
val container = dayInput(1)
    .groupBy { it.toInt() }
    .map { it.key to it.value.count() }

// Part 1
val part1Result = containers
    .sortedByDescending { (_, count) -> count }
    .take(3)
    .fold(1) { acc, pair -> acc * pair.first}

// Part 2
val part2Result = containers
    .sortedBy { (_, count) -> count }
    .take(3)
    .fold(1) { acc, pair -> acc * pair.first}

I felt inspired and motivated to draw a little illustration to go with that post, because why the hell not?