kotlin

Advent of Code 2021 in Kotlin - Day 3

Day 3’s problem has us work out what the most common bit is per column concatenating them to find the gamma value. The epsilon value is the inverse. Given the following input, 00100 11110 10110 10111 10101 01111 00111 11100 10000 11001 00010 01010 we’d have a gamma of 10110 and epsilon of 01001. The result is the product of the gamma and epsilon. buildString provides a string builder as an expression, letting us yield characters and strings.

Advent of Code 2021 in Kotlin - Day 2

It’s the 14th and I’m just writing about day 2, which is pretty much what I expected to happen. If the trajectory is linear it’s not too bad, I’ll at least be done in time for AOC 2022. Day 2’s problem has us read commands and update our position with the following rules: forward X increases the horizontal position by X units. down X increases the depth by X units.

Advent of Code 2021 in Kotlin - Day 1

Advent of Code seems to be very well put together, but I’ve never had a go before. I’ve also been meaning to learn a bit of Kotlin, so I figured I’ll put the two together. At least for one day, no promises on doing all 25. Part 1 The first problem is here. We’re given a list of depth measurements and need to work out how many measurements increase from the day before.