In this series, I'll share my progress with the 2025 version of Advent of Code.
I'll try to post my solution to the puzzle on the day it's unlocked on the website. Let's see how far I get this year. The previous year I did not participate, and in 2023 I did make it to the end, but well after December 25...
Good for me this year: only 12 days of puzzles, so I really plan on finishing before x-mas.
My solutions are not the most sophisticated, or the smallest, or the fastest, etc. I only have an hour or so each day to work on the puzzles. Still, I hope you like reading along with my coding adventures, and perhaps compare your solutions with mine, let me know in the comments below!
You can also follow my progress on GitHub.
A bit on my setup
This year, I'll be using C++. The main reason to pick C++ is that I want to catch up with language features that have been introduced in the last 5 10 15 20 years.
Rules I try to adhere to:
- I write all the code in a single file (
main.cpp) using the JetBrains CLion IDE (an IDE because I really need the autocomplete/linter support for my rusty C++ skills) - A solution should be less than 100 lines, if it's bigger I try to refactor/be smarter
- I only use code from the standard C++ library, no third-party libraries
- I only use Google/StackOverflow/Claude for basic C++ language stuff, no complete solutions ๐
December 1st
The puzzle of day 1 did not take me that long. Quite a soft landing this year ๐
My pitfall for this puzzle: I wanted to use a more elegant Dequeue implementation, but in the end stuck with the ugly if-then-else solution.
Solution here, do not click if you want to solve the puzzle first yourself
#include <cassert>
#include <fstream>
#include <iostream>
std::vector<std::pair<char, int>> loadInput(const std::string &filename) {
std::vector<std::pair<char, int>> instructions;
std::ifstream file(filename);
std::string line;
while (std::getline(file, line)) {
char direction = line[0];
int distance = std::stoi(line.substr(1));
instructions.emplace_back(direction, distance);
}
return instructions;
}
int calculateZeros(const std::vector<std::pair<char, int>> &instructions, const bool countPassZero = false) {
int dial = 50;
int zeros = 0;
for (auto i : instructions) {
auto [direction, count] = i;
if (count >= 100) {
if (countPassZero) {
zeros += count / 100;
}
count = count % 100;
}
if (direction == 'L') {
int nextDial = dial - count;
if (nextDial < 0) {
if (countPassZero && dial > 0) {
zeros++;
}
nextDial = 100 + nextDial;
}
dial = nextDial;
} else {
int nextDial = dial + count;
if (nextDial >= 100) {
if (countPassZero && nextDial != 100) {
zeros++;
}
nextDial = nextDial % 100;
}
dial = nextDial;
}
if (dial == 0) {
zeros++;
}
}
return zeros;
}
void partOne() {
auto instructions = loadInput("/Users/rob/projects/robvanderleek/adventofcode/2025/01/input.txt");
auto result = calculateZeros(instructions);
std::cout << result << std::endl;
assert(result == 1064);
}
void partTwo() {
const auto instructions = loadInput("/Users/rob/projects/robvanderleek/adventofcode/2025/01/input.txt");
const auto result = calculateZeros(instructions, true);
std::cout << result << std::endl;
assert(result == 6122);
}
int main() {
partOne();
partTwo();
return 0;
}
That's it! See you again tomorrow!

Top comments (0)