Complete 2023 to 2019 and 2016 to 2015 entries for the annual Advent of Code challenge, written in performant Rust.
- Each solution is blazing fast, using the most efficient algorithms to the best of my knowledge.
- Clean, elegant and idiomatic code.
- Consistently formatted with
rustfmt
and linted byclippy
. - Thoroughly commented with
rustdoc
generated documentation online. - Test coverage with continuous integration provided by GitHub Actions.
- Self contained depending only on the stable
std
Rust library. No use ofunsafe
features.
Show details
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
Benchmarks are measured using the built-in cargo bench
tool run on an
Apple M2 Max.
All 175 solutions from 2023 to 2019 and also 2016 to 2015 complete sequentially in 1.1 seconds.
Interestingly 90% of the total time is spent on just 5 solutions.
Performance is reasonable even on older hardware, for example a 2011 MacBook Pro with an
Intel i7-2720QM
processor takes 4.1 seconds to run the same 175 solutions.
%%{init: {"themeVariables": { "pie1": "#7cb5ec", "pie2": "#90ed7d", "pie3": "#f7a35c", "pie4": "#e4d354", "pie5": "#e4c4fb", "pie6": "#c6cdd5"}}}%%
pie
title Each year benchmark time by % of total
"Year 2016" : 663
"Year 2020" : 286
"Year 2015" : 87
"Years 2019, 2021, 2022 and 2023" : 52
- 2023 (10 ms)
- 2022 (10 ms)
- 2021 (10 ms)
- 2020 (286 ms)
- 2019 (22 ms)
- 2017 (in progress)
- 2016 (663 ms)
- 2015 (87 ms)
%%{init: {"themeVariables": { "pie1": "#7cb5ec", "pie2": "#90ed7d", "pie3": "#f7a35c", "pie4": "#e4d354", "pie5": "#c6cdd5"}}}%%
pie
title Year 2023 benchmark time by % of total
"Day 23" : 3181
"Day 17" : 2463
"Day 12" : 1150
"Day 16" : 831
"Others" : 2206
Day | Problem | Solution | Benchmark (μs) |
---|---|---|---|
1 | Trebuchet?! | Source | 35 |
2 | Cube Conundrum | Source | 10 |
3 | Gear Ratios | Source | 55 |
4 | Scratchcards | Source | 18 |
5 | If You Give A Seed A Fertilizer | Source | 13 |
6 | Wait For It | Source | 1 |
7 | Camel Cards | Source | 97 |
8 | Haunted Wasteland | Source | 34 |
9 | Mirage Maintenance | Source | 19 |
10 | Pipe Maze | Source | 60 |
11 | Cosmic Expansion | Source | 12 |
12 | Hot Springs | Source | 1150 |
13 | Point of Incidence | Source | 64 |
14 | Parabolic Reflector Dish | Source | 661 |
15 | Lens Library | Source | 83 |
16 | The Floor Will Be Lava | Source | 831 |
17 | Clumsy Crucible | Source | 2463 |
18 | Lavaduct Lagoon | Source | 19 |
19 | Aplenty | Source | 100 |
20 | Pulse Propagation | Source | 6 |
21 | Step Counter | Source | 180 |
22 | Sand Slabs | Source | 486 |
23 | A Long Walk | Source | 3181 |
24 | Never Tell Me The Odds | Source | 96 |
25 | Snowverload | Source | 157 |
%%{init: {"themeVariables": { "pie1": "#7cb5ec", "pie2": "#90ed7d", "pie3": "#f7a35c", "pie4": "#c6cdd5"}}}%%
pie
title Year 2022 benchmark time by % of total
"Day 20" : 5067
"Day 23" : 2017
"Day 11" : 1172
"Others" : 1145
Day | Problem | Solution | Benchmark (μs) |
---|---|---|---|
1 | Calorie Counting | Source | 14 |
2 | Rock Paper Scissors | Source | 4 |
3 | Rucksack Reorganization | Source | 15 |
4 | Camp Cleanup | Source | 7 |
5 | Supply Stacks | Source | 14 |
6 | Tuning Trouble | Source | 3 |
7 | No Space Left On Device | Source | 10 |
8 | Treetop Tree House | Source | 55 |
9 | Rope Bridge | Source | 122 |
10 | Cathode-Ray Tube | Source | 2 |
11 | Monkey in the Middle | Source | 1172 |
12 | Hill Climbing Algorithm | Source | 59 |
13 | Distress Signal | Source | 16 |
14 | Regolith Reservoir | Source | 205 |
15 | Beacon Exclusion Zone | Source | 2 |
16 | Proboscidea Volcanium | Source | 60 |
17 | Pyroclastic Flow | Source | 68 |
18 | Boiling Boulders | Source | 129 |
19 | Not Enough Minerals | Source | 71 |
20 | Grove Positioning System | Source | 5067 |
21 | Monkey Math | Source | 61 |
22 | Monkey Map | Source | 55 |
23 | Unstable Diffusion | Source | 2017 |
24 | Blizzard Basin | Source | 80 |
25 | Full of Hot Air | Source | 3 |
%%{init: {"themeVariables": { "pie1": "#7cb5ec", "pie2": "#90ed7d", "pie3": "#f7a35c", "pie4": "#c6cdd5"}}}%%
pie
title Year 2021 benchmark time by % of total
"Day 15" : 2567
"Day 20" : 2075
"Day 23" : 1717
"Others" : 2832
Day | Problem | Solution | Benchmark (μs) |
---|---|---|---|
1 | Sonar Sweep | Source | 6 |
2 | Dive! | Source | 11 |
3 | Binary Diagnostic | Source | 20 |
4 | Giant Squid | Source | 11 |
5 | Hydrothermal Venture | Source | 179 |
6 | Lanternfish | Source | 1 |
7 | The Treachery of Whales | Source | 1 |
8 | Seven Segment Search | Source | 16 |
9 | Smoke Basin | Source | 55 |
10 | Syntax Scoring | Source | 33 |
11 | Dumbo Octopus | Source | 58 |
12 | Passage Pathing | Source | 27 |
13 | Transparent Origami | Source | 32 |
14 | Extended Polymerization | Source | 12 |
15 | Chiton | Source | 2567 |
16 | Packet Decoder | Source | 5 |
17 | Trick Shot | Source | 7 |
18 | Snailfish | Source | 461 |
19 | Beacon Scanner | Source | 554 |
20 | Trench Map | Source | 2075 |
21 | Dirac Dice | Source | 282 |
22 | Reactor Reboot | Source | 398 |
23 | Amphipod | Source | 1717 |
24 | Arithmetic Logic Unit | Source | 4 |
25 | Sea Cucumber | Source | 621 |
%%{init: {"themeVariables": { "pie1": "#7cb5ec", "pie2": "#90ed7d", "pie3": "#c6cdd5"}}}%%
pie
title Year 2020 benchmark time by % of total
"Day 15" : 160000
"Day 23" : 110000
"Others" : 16671
Day | Problem | Solution | Benchmark (μs) |
---|---|---|---|
1 | Report Repair | Source | 11 |
2 | Password Philosophy | Source | 35 |
3 | Toboggan Trajectory | Source | 11 |
4 | Passport Processing | Source | 43 |
5 | Binary Boarding | Source | 12 |
6 | Custom Customs | Source | 35 |
7 | Handy Haversacks | Source | 55 |
8 | Handheld Halting | Source | 7 |
9 | Encoding Error | Source | 9 |
10 | Adapter Array | Source | 1 |
11 | Seating System | Source | 4847 |
12 | Rain Risk | Source | 11 |
13 | Shuttle Search | Source | 1 |
14 | Docking Data | Source | 79 |
15 | Rambunctious Recitation | Source | 160000 |
16 | Ticket Translation | Source | 102 |
17 | Conway Cubes | Source | 414 |
18 | Operation Order | Source | 26 |
19 | Monster Messages | Source | 384 |
20 | Jurassic Jigsaw | Source | 38 |
21 | Allergen Assessment | Source | 51 |
22 | Crab Combat | Source | 6105 |
23 | Crab Cups | Source | 110000 |
24 | Lobby Layout | Source | 4346 |
25 | Combo Breaker | Source | 24 |
%%{init: {"themeVariables": { "pie1": "#7cb5ec", "pie2": "#90ed7d", "pie3": "#f7a35c", "pie4": "#e4d354", "pie5": "#c6cdd5"}}}%%
pie
title Year 2019 benchmark time by % of total
"Day 16" : 4124
"Day 13" : 3492
"Day 25" : 2721
"Day 21" : 2265
"Others" : 10445
Day | Problem | Solution | Benchmark (μs) |
---|---|---|---|
1 | The Tyranny of the Rocket Equation | Source | 1 |
2 | 1202 Program Alarm | Source | 1 |
3 | Crossed Wires | Source | 19 |
4 | Secure Container | Source | 7 |
5 | Sunny with a Chance of Asteroids | Source | 3 |
6 | Universal Orbit Map | Source | 28 |
7 | Amplification Circuit | Source | 275 |
8 | Space Image Format | Source | 5 |
9 | Sensor Boost | Source | 1356 |
10 | Monitoring Station | Source | 1001 |
11 | Space Police | Source | 470 |
12 | The N-Body Problem | Source | 1024 |
13 | Care Package | Source | 3492 |
14 | Space Stoichiometry | Source | 17 |
15 | Oxygen System | Source | 442 |
16 | Flawed Frequency Transmission | Source | 4124 |
17 | Set and Forget | Source | 425 |
18 | Many-Worlds Interpretation | Source | 1077 |
19 | Tractor Beam | Source | 817 |
20 | Donut Maze | Source | 191 |
21 | Springdroid Adventure | Source | 2265 |
22 | Slam Shuffle | Source | 11 |
23 | Category Six | Source | 871 |
24 | Planet of Discord | Source | 139 |
25 | Cryostasis | Source | 2721 |
Day | Problem | Solution | Benchmark (μs) |
---|---|---|---|
1 | Inverse Captcha | Source | 1 |
2 | Corruption Checksum | Source | 3 |
3 | Spiral Memory | Source | 2 |
4 | High-Entropy Passphrases | Source | 94 |
5 | A Maze of Twisty Trampolines, All Alike | Source | 48000 |
6 | Memory Reallocation | Source | 81 |
7 | Recursive Circus | Source | 85 |
8 | I Heard You Like Registers | Source | 46 |
9 | Stream Processing | Source | 13 |
10 | Knot Hash | Source | 61 |
11 | Hex Ed | Source | 20 |
12 | Digital Plumber | Source | 59 |
13 | Packet Scanners | Source | 2 |
14 | Disk Defragmentation | Source | 422 |
%%{init: {"themeVariables": { "pie1": "#7cb5ec", "pie2": "#90ed7d", "pie3": "#c6cdd5"}}}%%
pie
title Year 2016 benchmark time by % of total
"Day 14" : 434000
"Day 5" : 212000
"Others" : 16696
Day | Problem | Solution | Benchmark (μs) |
---|---|---|---|
1 | No Time for a Taxicab | Source | 3 |
2 | Bathroom Security | Source | 9 |
3 | Squares With Three Sides | Source | 26 |
4 | Security Through Obscurity | Source | 75 |
5 | How About a Nice Game of Chess? | Source | 212000 |
6 | Signals and Noise | Source | 5 |
7 | Internet Protocol Version 7 | Source | 354 |
8 | Two-Factor Authentication | Source | 10 |
9 | Explosives in Cyberspace | Source | 6 |
10 | Balance Bots | Source | 17 |
11 | Radioisotope Thermoelectric Generators | Source | 785 |
12 | Leonardo's Monorail | Source | 1 |
13 | A Maze of Twisty Little Cubicles | Source | 4 |
14 | One-Time Pad | Source | 434000 |
15 | Timing is Everything | Source | 1 |
16 | Dragon Checksum | Source | 1 |
17 | Two Steps Forward | Source | 14254 |
18 | Like a Rogue | Source | 743 |
19 | An Elephant Named Joseph | Source | 1 |
20 | Firewall Rules | Source | 23 |
21 | Scrambled Letters and Hash | Source | 10 |
22 | Grid Computing | Source | 31 |
23 | Safe Cracking | Source | 1 |
24 | Air Duct Spelunking | Source | 335 |
25 | Clock Signal | Source | 1 |
%%{init: {"themeVariables": { "pie1": "#7cb5ec", "pie2": "#90ed7d", "pie3": "#c6cdd5"}}}%%
pie
title Year 2015 benchmark time by % of total
"Day 4" : 76000
"Day 6" : 5780
"Others" : 3037
Day | Problem | Solution | Benchmark (μs) |
---|---|---|---|
1 | Not Quite Lisp | Source | 2 |
2 | I Was Told There Would Be No Math | Source | 8 |
3 | Perfectly Spherical Houses in a Vacuum | Source | 100 |
4 | The Ideal Stocking Stuffer | Source | 76000 |
5 | Doesn't He Have Intern-Elves For This? | Source | 39 |
6 | Probably a Fire Hazard | Source | 5780 |
7 | Some Assembly Required | Source | 27 |
8 | Matchsticks | Source | 12 |
9 | All in a Single Night | Source | 35 |
10 | Elves Look, Elves Say | Source | 14 |
11 | Corporate Policy | Source | 1 |
12 | JSAbacusFramework.io | Source | 80 |
13 | Knights of the Dinner Table | Source | 39 |
14 | Reindeer Olympics | Source | 28 |
15 | Science for Hungry People | Source | 41 |
16 | Aunt Sue | Source | 21 |
17 | No Such Thing as Too Much | Source | 43 |
18 | Like a GIF For Your Yard | Source | 161 |
19 | Medicine for Rudolph | Source | 188 |
20 | Infinite Elves and Infinite Houses | Source | 1671 |
21 | RPG Simulator 20XX | Source | 3 |
22 | Wizard Simulator 20XX | Source | 257 |
23 | Opening the Turing Lock | Source | 6 |
24 | It Hangs in the Balance | Source | 360 |
25 | Let It Snow | Source | 1 |