Posted on: 2025-12-01, Updated on: 2025-12-01 05:58:35 | Read time: 1.3 minutes
Topic(s): programming
Advent of Code is the December tradition where thousands of programmers race to solve puzzles at midnight (EST/UTC-5) to earn stars and help Santa’s elves until Christmas. Each problem has two parts and you earn a star for each part that you complete. The problems start out easy and become progressively more difficult. You can use any programming language to solve the problems, and many people use it as an opportunity to learn a new language.
This years Advent of Code will feature twelve problems, and I will attempt to document my solutions for both parts of each day's problem. With fewer problems this year, I'm assuming that the difficulty will ramp up faster than I've been used to with previous years. My goal for this year is to at least make it to day six. I've decided to use the C++ programming language to solve the problems this time.
NOTE: It should go without saying that this article will contain spoilers for the given day's Advent of Code problem. I will eventually add a spoiler element to my blog to hide the solution's source code. Nevertheless, continue reading at your own risk!
// Advent of Code 2025 - Day 01
#include "AdventOfCodeStd.hpp"
using namespace AOC;
int main(void)
{
std::vector<std::pair<char, int>> rotations;
for (std::string s; std::getline(std::cin, s);)
{
rotations.emplace_back(s[0], std::stoi(s.substr(1)));
}
// for (const auto &rot : rotations)
// std::cout << rot.first << rot.second << '\n';
int pos{ 50 };
int count0{};
for (const auto &[dir, dist] : rotations)
{
pos = (pos + ((dir == 'R') ? dist : -dist)) % 100;
count0 = count0 + ((pos == 0) ? 1 : 0);
}
std::cout << count0 << '\n';
return 0;
}
The first part of this solution for Part 1 stores the input rotations in a std::vector of std::pair<char, int>'s. The first element in the pair stores the direction and the second the distance of that rotation. A variable pos, used to store the current position of the circular dial, is initialized to 50 to match the problem text. The count0 variable stores the number of times the dial has stopped at 0 after a rotation in the sequence. The rotations are iterated through to count the number of zeros by applying the rotations to the dial position. Note that the negative remainder is sufficient for Part 1, but it will have to be properly normalized within the 0 to 99 range for Part 2.
Thanks for reading, and stay tuned for more articles about this year's Advent of Code!
Resources: