Welcome to my repository of Advent of Code solutions written in C++. This repository contains my attempts at solving the annual programming challenge series.
Advent of Code is an annual event featuring a series of programming puzzles released daily from December 1st through December 12th. Each day presents two related problems that increase in difficulty as the event progresses. Participants earn one star for solving each puzzle.
Solutions are organized by year and day:
advent-of-code-cpp/
├── 2025/
│ ├── day_1/
│ │ ├── README.md (problem description)
│ │ ├── main.cpp (solution)
│ │ └── input.txt (puzzle input)
│ ├── day_2/
│ ├── day_3/
│ └── ...
├── .gitignore
├── LICENSE
└── README.md (this file)
- C++17 or later
- A C++ compiler (g++, clang, MSVC, etc.)
For individual solutions:
cd 2025/day_1
g++ -std=c++17 -O2 main.cpp -o solution
./solutionMost solutions read from an input.txt file in the same directory.
-
Day 1 - Secret Entrance: Safe dial rotation puzzle with two different counting methods
- Part 1: Count times dial lands on 0 after rotations
- Part 2: Count all times dial passes through 0, including during rotations
-
Day 2 - Gift Shop: Invalid product ID detection
- Part 1: Find IDs that are exact digit pattern repetitions (exactly 2 times)
- Part 2: Find IDs that are digit pattern repetitions (2+ times)
-
Day 3 - Lobby: Battery joltage selection from digit banks
- Part 1: Find maximum joltage using 2 digits per bank
- Part 2: Find maximum joltage using 12 digits per bank
Each solution prioritizes:
- Correctness - Solving the puzzle accurately
- Efficiency - Reasonable performance, especially for large inputs
- Readability - Clear code structure with meaningful variable names
Where appropriate, solutions include optimized implementations (e.g., mathematical approaches over brute force).
This is a personal practice repository, but feel free to fork it or use it as reference for your own solutions!
This repository is for educational purposes. Advent of Code is created by Eric Wastl.
For more information, visit adventofcode.com.