This repository contains my solutions to the Advent of Code 2024 puzzles. This is my first time participating in the event. I decided to use it as an opportunity to reflect on how far I've come as a self-taught programmer. It also serves as my attempt to strike a good balance between simplicity and performance in the solutions.
This repository is a Cargo virtual manifest. Each puzzle solution is located in a separate binary crate, along with some benchmarking code and minimal tests.
The input for each puzzle is fed by providing the path to an input file after starting the program.
Sample inputs for tests are provided through sample_input.txt
files and embedded at compile-time into the binary.
Many of the functions used in the solutions are generic over the data type used for calculations. This allows optimizing the underlying data type to optimize performance based on benchmarks.
At the time of writing, compiling the solutions requires a nightly version of Rust. You can install it with rustup.
rustup install nightly
Solutions can be executed with Cargo either by entering the directory containing a challenge and running the project
cd day1
cargo run
or by specifying the binary directly.
cargo run --release --bin day1
Most of the code items in this repository are (minimally) documented using doc comments.
You can view the documentation for each solution as well as dependencies by running cargo doc
on the repository.
cargo doc --open
I have provided basic tests for each solution. These cover the sample inputs provided in each challenge, as well as additional test cases I used to verify the correctness of the solutions during implementation.
The solutions can be tested by running cargo test
on the repository.
cargo test
I have provided basic benchmark tests for some of the solutions.
You can run the benchmarks by running cargo bench
on the repository.
cargo bench
You're welcome to analyze the implementation of the benchmarking code and the solutions themselves. All benchmarking functions are marked with the #[bench]
attribute.