Home

Awesome

ci

🎄 Advent of Code 2023 Solutions 🎄

Welcome to my repository where I share my solutions to the Advent of Code 2023 challenges, tackled using the good old C programming language. Advent of Code is an annual December event where programmers solve fun, holiday-themed puzzles.

🛠 Usage

Each puzzle solution is compiled into its own standalone executable, named in accordance with its corresponding day. For instance, the executable for the first puzzle is day01. By default, these executables search for their respective input files located at input/dayXX.txt, where XX represents the two-digit day number (e.g., 01 for Day 1). Alternatively, you have the option to provide input via a command-line argument. For example, you can run ./day01 mine.txt to specify a different input file.

🏗 Building and Running Tests

Each puzzle in this repository is accompanied by tests, which are designed using both the examples provided in the puzzle and the actual input.txt file. Since sharing the puzzle input data is discouraged, the inputs have been encrypted.

Note: Tests using the actual input.txt have to be enabled at compile time with the -Dhave-inputs=true option (this only make sense if you have my input.txt files since your answers will differ from mine).

Release Build

meson setup --buildtype=release -Db_lto=true -Dhave-inputs=true build
ninja -C build test

Debug Build

meson setup --buildtype=debugoptimized -Db_sanitize=address -Db_lundef=false -Dhave-inputs=true build_debug
ninja -C build_debug test

⏱ Performance Benchmarks

The solutions were tested on different processors using hyperfine and/or poop. Compiled using clang 16 and LTO.

DayIntel i7-11850HAMD Ryzen 5 PRO 4650U
1276 µs520 µs
2185 µs434 µs
3231 µs501 µs
4368 µs679 µs
51.4 s2.6 s
6200 µs472 µs
72.6 ms3.54 ms
8462.4 µs1 ms
9256 µs464 µs
105.8 ms16.4 ms
11980 µs1.7 ms
12347 ms554 ms
13248 µs486 µs
1444 ms53.4 ms
151.1 ms1 ms
1634.4 ms33.5 ms
17315.3 ms604 ms
18173 µs379 µs
19422 µs891 µs
1916.8 ms

🙏 Acknowledgments and Resources

Special thanks to the authors of these very useful C resources: