This is my attempt for Advent of Code using C++. I will probably shift back to Python at some point, stop me before I do that :)
The current build system is ingenious. We build the solution for Day <day_number> ( and optionally the year <yr_number> ) using the following command.
make build DAY=<day_number> ( YEAR=<yr_number> )
This places the solution executable in build/, and the relevant call to make run DAY=<day_number>
will execute the file. make run
will print the answers out. Similarly,
make bench DAY=<day_number> ( YEAR=<yr_number> )
will benchmark the code. This will not print out the answers out.
Each solution is actually implemented as a header ! Furthermore, on the completed implementation of each file, we tag it with a #define as follows:
#define PART_1
int part1() {
...
}
Then, depending on the mode ( run
vs bench
), we link these headers to different main files, found in utils/. Each of these main files checks for these constants, and executes the part that they detect.