diff --git a/README.md b/README.md new file mode 100644 index 0000000..69dbb7c --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# Advent of Code 2025 + +https://adventofcode.com/2025 + +## Building +Everything is handled by cmake which most ide's can handle. +Make sure you have a compiler (MSVC or GCC), CMake, and make/ninja installed. + +If you're using make to build the project, run the following commands: +1. `mkdir build` +2. `cd build` +3. `cmake .. -G "Unix Makefiles"` +4. `make -j ` + +If you're using ninja to build the project, run the following commands: +1. `mkdir build` +2. `cd build` +3. `cmake .. -G Ninja` +4. `ninja` + +## Directory structure + +- `src`: Contains the source code for each day. +- `src/common`: Contains some generalized headers that are used by multiple days. +- `src/dayX`: Contains the source code for day `X +- `src/dayx/pY`: Contains the source code for part `Y` of day `X` +- `input`: Contains the input for each day. + +## Types +During this challenge, I plan to have multiple different +types of solutions. + +- Normal: A more "normal" solution, opting for more readable code without doing anything fancy. +- Faf: The fastest solution I can think of. + +Each solution has its own executable following the following naming convention: `dXpY-type`. Where `X` is the day number, `pY` is the part number, and `type` is the type of solution (Normal omits the type all together Ex: a normal day1 part1 executable would be `d1p1`). + +## Benchmarks + +All benchmarks are running using the timer class defined in `src/common/timer.h`.
+"Normal" solutions are only run once, as they aren't designed to be as fast as possible.
+"Faf" solutions are run multiple times to get a more accurate average.
+All benchmarks include file IO, mostly because everything calculates within single digit microseconds or less. + +All benchmarks are run on a system with the following specs: +- CPU: AMD Ryzen 9 8945HS +- RAM: 32GB DDR5 6000MHz +- SSD: Samsung 990 Pro +- OS: Windows 11 24H2 +- Compiler: gcc version 13.2.0 (x86_64-posix-seh-rev0, Built by MinGW-Builds project) + +| Day | Part | Type | Time (us) | Iterations | +|-----|------|--------|-----------|------------| +| 1 | 1 | faf | 43 | 100000 | +| 1 | 1 | Normal | 483 | 1 | +| 1 | 2 | Normal | 472 | 1 | diff --git a/src/common/timer.h b/src/common/timer.h index 85eac3c..3f2f930 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -30,7 +30,7 @@ public: for (const auto &[name, time] : points) { std::cout << "\t" << name << ": " << std::chrono::duration_cast(time - start).count() << " ms | " << std::chrono::duration_cast(time - start).count() << " us" << std::endl; } - std::cout << "Global: " << std::chrono::duration_cast(end - start).count() / iterations << " ms | " << std::chrono::duration_cast(end-start).count() / iterations << " us" << std::endl; + std::cout << "Global (" << iterations << "): " << std::chrono::duration_cast(end - start).count() / iterations << " ms | " << std::chrono::duration_cast(end-start).count() / iterations << " us" << std::endl; } private: diff --git a/src/day1/p1/faf.cpp b/src/day1/p1/faf.cpp index 43a47f5..39c45ae 100644 --- a/src/day1/p1/faf.cpp +++ b/src/day1/p1/faf.cpp @@ -66,7 +66,7 @@ #include "timer.h" int main() { - constexpr int iterations = 1000; + constexpr int iterations = 100000; Timer timer(iterations); int password = 0;