My Advent of Code 2024 solutions in the Rust programming language. This repository holds a separate Rust project for each day and part.
I attempt to develop a standalone, elegant, compact and fast solution for each problem (two each day).
Three years ago I did the same, solving everything in under a second:
- https://timvisee.com/blog/solving-aoc-2020-in-under-a-second/
- https://github.com/timvisee/advent-of-code-2021
- https://github.com/timvisee/advent-of-code-2020
Here is how long each solution runs with my input. All solutions are measured
(non scientifically) in bench.rs
on an AMD Ryzen 9 5900X (24) @ 3.7GHz
machine running Linux.
part A | part B | |
---|---|---|
day 1 | 0.021 ms |
0.022 ms |
day 2 | 0.034 ms |
0.073 ms |
day 3 | 0.118 ms |
0.206 ms |
day 4 | 0.148 ms |
0.026 ms |
day 5 | 0.089 ms |
0.150 ms |
one-by-one (1 CPU core) | parallel | |
---|---|---|
everything | 0.89 ms |
0.20 ms |
Each Rust project needs a input.txt
file to run, holding the puzzle input.
Simply create this file with your input and run the project to see the solution
appear.
# Switch to day 1a, add input, and run it
cd day01a
nano input.txt
cargo +nightly run --release
# or run everything in parallel
cd ../runner
cargo +nightly run --release --bin runner-par
# or benchmark every day
cd ../runner
cargo +nightly run --release --bin bench
Some solutions require Rust Nightly, that's why +nightly
is included.
Sadly I cannot include my puzzle input anymore to make each solution easily runnable as per Advent of Code FAQ:
If you're posting a code repository somewhere, please don't include parts of Advent of Code like the puzzle text or your inputs.
This project is released under the GNU GPL-3.0 license. Check out the LICENSE file for more information.