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....
Recently on Hacker News I saw that Zig 0.9.0 was released and it rekindled my interest in this language. Besides reading the Why Zig When There is Already C++, D, and Rust? page and a few other pages from the docs I’ve never tried to use it, so instead of moving on to day 3 in Kotlin I thought I’d start again (at least for one day) in Zig. I haven’t read all the docs yet, so there’s no doubt that what I’ve come up with is not ideal....
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 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....