Skip to content

michel-kraemer/adventofcode-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advent of Code

These are my solutions to the annual Advent of Code challenge.

Goals

🦀 Implement everything in Rust

👍 Find generalized solutions that work with every input

⛓️‍💥 Avoid 3rd party dependencies (if possible and reasonable)

🏃‍♂️‍➡️ Try to optimize performance (to the best of my knowledge and if it doesn't conflict with the other goals). See benchmarks below.

🤓 Find clever solutions to complex problems that others might not have found. Some highlights I'm particularly proud of:

  • Day 25 of 2018: Combining DBSCAN with a spatial index based on Morton indices. Very fast!
  • Day 21 of 2023: Applying bit operations to simulate the cellular automaton, which allowed me to implement a fast and generalized solution that should work on any input.
  • Day 25 of 2023: Using Brandes' algorithm to quickly calculate the betweenness centrality of graph nodes.
  • Day 10 of 2025: While most people approached this problem using a solver (such as S3 or good_lp), I found a solution that works completely without a 3rd party dependency. I implemented a DFS in which I use heuristics to prune as many branches as possible. This is definitely not the fastest approach possible, but it gets the job done in reasonable time and is certainly quite unique. See my Reddit comment for more information.

Terminal visualizations

I've created terminal visualizations of some puzzles for fun:


2019 - Day 13: Care Package

2024 - Day 15: Warehouse Woes

2025 - Day 4: Printing Department

2025 - Day 12: Christmas Tree Farm

If you want to visualize your own input with my code, just change into the solution's directory (e.g. cd 2025/day12) and run the following command:

AOC_VISUALIZE=true cargo run --release

Benchmarks

All measurements were performed with my cargo bench-aoc tool on a MacBook Pro 16″ 2023 with an Apple M3 Pro processor. The tool uses Criterion.rs under the hood to provide accurate and reproducible benchmark results. I/O (reading input files and printing answers to the terminal) is NOT included in the benchmark results.

2015

Day 1:6µs Day 2:42µs Day 3:415µs Day 4:633ms Day 5:168µs
Day 6:6ms Day 7:23µs Day 8:7µs Day 9:19µs Day 10:16ms
Day 11:8ms Day 12:125µs Day 13:42µs Day 14:23µs Day 15:3ms
Day 16:49µs Day 17:43µs Day 18:... Day 19:... Day 20:...
Day 21:... Day 22:... Day 23:... Day 24:... Day 25:...

License

The solutions are released under the MIT license. See the LICENSE file for more information.