Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabberr/aoc2024
Solutions for Advent of Code 2024 puzzles written in C++
https://github.com/fabberr/aoc2024
advent-of-code advent-of-code-2024 aoc aoc-2024-in-cpp aoc2024 cpp cpp26 programming-challenge
Last synced: about 1 month ago
JSON representation
Solutions for Advent of Code 2024 puzzles written in C++
- Host: GitHub
- URL: https://github.com/fabberr/aoc2024
- Owner: fabberr
- License: gpl-3.0
- Created: 2024-11-16T17:12:35.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2024-12-05T01:03:33.000Z (about 2 months ago)
- Last Synced: 2024-12-05T02:18:50.707Z (about 2 months ago)
- Topics: advent-of-code, advent-of-code-2024, aoc, aoc-2024-in-cpp, aoc2024, cpp, cpp26, programming-challenge
- Language: C++
- Homepage: https://adventofcode.com/2024
- Size: 63.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Advent of Code 2024 (C++)
Solutions for [Advent of Code 2024](https://adventofcode.com/2024) puzzles written in C++.
## Solutions
Solutions are implemented by creating a new C++ source file in `src/solutions` and implementing the two functions declared `include/aoc2024/solution.hpp`, one for each of the day's puzzles. The inputs for the day should be placed in a text file located in `src/input`.
The entry point is defined in `src/main.cpp`, and already implements basic command line parsing and file handling logic.
The program accepts the following arguments:
1. ``: Path to the file containing the inputs for the day.
2. ``: Selects which puzzle to solve for, `a` for the first puzzle, and `b` for the second one.A sample implementation is provided in `src/solutions/day00.cpp`, with its inputs in `src/input/day00.txt`.
## Building
To build a solution, use the following compiler flags: `-std=c++26 -Iinclude`
- Note: Only ONE implementation of `solution.hpp` should be provided.```bash
# Ensure output directory exists and build the solution
$ mkdir -p build; g++ -std=c++26 -Iinclude -o build/dayXX ./src/main.cpp ./src/solutions/dayXX.cpp
```## Automation
`aoc2024.sh` is a shell script for automating the process of implementing and running solutions by making use of [GNU Make](https://www.gnu.org/software/make). The script will create all the necessary files/targets for building and running solutions.
Note that the script was designed to use paths _relative to the root directory_ of this repository and will refuse to run if called from elsewhere.
The script accepts two commands:
- `new `: Cretes a new solution by creating an empty input file and the source file implementing `solution.hpp`. Two Make targets for building and running the solution will also be created.
- `run [args]`: Runs a solution with the specified command line arguments. If the executable is not found in the `build` directory, the build target is invoked first.Example usage:
```bash
# Ensure the execute file mode bit is set for your user:
$ chmod u+x ./aoc2024.sh# To create a new solution (e.g. Day 1 of the event):
$ ./aoc2024.sh new day01# To build and run the first puzzle of the solution:
$ ./aoc2024.sh run day01 a
```