Awesome
Advent of Code
Complete 2023 to 2015 entries written in Rust for the annual Advent of Code challenge, solving 450 stars in less than 1 second.
Features
- Each solution uses the most efficient algorithms to the best of my knowledge.
- Self contained depending only on the
std
Rust library. No use ofunsafe
features. - Consistently formatted with
rustfmt
and linted byclippy
. - Thoroughly commented with
rustdoc
generated documentation online. - Test coverage with continuous integration provided by GitHub Actions.
Quickstart
<details> <summary>Show details</summary><p/>Input
Place input files in input/yearYYYY/dayDD.txt
including leading zeroes. For example:
input/year2015/day23.txt
input/year2023/day02.txt
Run
- Everything
cargo run
- Specific year
cargo run year2023
- Specific day
cargo run year2023::day01
- Release profile (faster)
cargo run --release
- Optimized for current CPU architecture (fastest)
RUSTFLAGS="-C target-cpu=native" cargo run --release
Test
- Everything
cargo test
- Specific year
cargo test year2023
- Specific day
cargo test year2023::day01
- Show STDOUT for debugging
cargo test -- --nocapture
Benchmark
- Everything
cargo bench
- Specific year
cargo bench year2023
- Specific day
cargo bench year2023::day01
Document
- Build docs including private items
cargo doc --document-private-items
- Build doc then open HTML landing page
cargo doc --document-private-items --open
Miscellaneous
- Code quality lints
cargo clippy
- Consistent code formatting
cargo fmt
Performance
Benchmarks are measured using the built-in cargo bench
tool run on an Apple M2 Max.
All 225 solutions from 2023 to 2015 complete sequentially in 579 milliseconds.
Interestingly 84% of the total time is spent on just 9 solutions.
Performance is reasonable even on older hardware, for example a 2011 MacBook Pro with an
Intel i7-2720QM processor takes 3.5 seconds to run the same 225 solutions.
Year | Benchmark (ms) |
---|---|
2023 | 6 |
2022 | 8 |
2021 | 9 |
2020 | 272 |
2019 | 16 |
2018 | 35 |
2017 | 89 |
2016 | 120 |
2015 | 24 |
2023
2022
2021
Day | Problem | Solution | Benchmark (μs) |
---|---|---|---|
1 | Sonar Sweep | Source | 6 |
2 | Dive! | Source | 12 |
3 | Binary Diagnostic | Source | 20 |
4 | Giant Squid | Source | 12 |
5 | Hydrothermal Venture | Source | 181 |
6 | Lanternfish | Source | 1 |
7 | The Treachery of Whales | Source | 8 |
8 | Seven Segment Search | Source | 14 |
9 | Smoke Basin | Source | 64 |
10 | Syntax Scoring | Source | 25 |
11 | Dumbo Octopus | Source | 55 |
12 | Passage Pathing | Source | 25 |
13 | Transparent Origami | Source | 22 |
14 | Extended Polymerization | Source | 11 |
15 | Chiton | Source | 2403 |
16 | Packet Decoder | Source | 6 |
17 | Trick Shot | Source | 7 |
18 | Snailfish | Source | 501 |
19 | Beacon Scanner | Source | 615 |
20 | Trench Map | Source | 2066 |
21 | Dirac Dice | Source | 278 |
22 | Reactor Reboot | Source | 378 |
23 | Amphipod | Source | 1714 |
24 | Arithmetic Logic Unit | Source | 4 |
25 | Sea Cucumber | Source | 551 |
2020
Day | Problem | Solution | Benchmark (μs) |
---|---|---|---|
1 | Report Repair | Source | 12 |
2 | Password Philosophy | Source | 35 |
3 | Toboggan Trajectory | Source | 12 |
4 | Passport Processing | Source | 49 |
5 | Binary Boarding | Source | 11 |
6 | Custom Customs | Source | 35 |
7 | Handy Haversacks | Source | 69 |
8 | Handheld Halting | Source | 8 |
9 | Encoding Error | Source | 9 |
10 | Adapter Array | Source | 1 |
11 | Seating System | Source | 4537 |
12 | Rain Risk | Source | 12 |
13 | Shuttle Search | Source | 1 |
14 | Docking Data | Source | 83 |
15 | Rambunctious Recitation | Source | 147000 |
16 | Ticket Translation | Source | 120 |
17 | Conway Cubes | Source | 443 |
18 | Operation Order | Source | 24 |
19 | Monster Messages | Source | 362 |
20 | Jurassic Jigsaw | Source | 42 |
21 | Allergen Assessment | Source | 45 |
22 | Crab Combat | Source | 5911 |
23 | Crab Cups | Source | 110000 |
24 | Lobby Layout | Source | 4320 |
25 | Combo Breaker | Source | 20 |