Skip to content
This repository has been archived by the owner. It is now read-only.

fyrchik/aoc2022rust

Repository files navigation

Advent of Code 2022 in Rust

This repo contains solutions to Advent of Code 2022 puzzles in Rust.

Last year I tried to stay within stable Rust. This year goals are:

  1. Be as fast as possible, possibly sacrificing input validation.
  2. Explore experimental features and const generics.
  3. Still have little to no dependencies, but be more liberal than I did last year.

Using

Firstly, put your input to src/dayNN/input.

# Run puzzle for a specific day.
make run/dayNN

# Run criterion benchmarks for a specific day.
make bench/dayNN

Timings

I copied the structure of this section from https://github.com/timvisee/advent-of-code-2022 . I also recommend that repo for seing some clean Rust code!

Here is how long each solution runs. All solutions are measured (non scientifically) in bench.rs on an Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz laptop running Linux. Having that in mind, the timings are close to those obtained (scientifically) with cargo criterion.

part A part B
day 1 0.011 ms 0.012 ms
day 2 0.012 ms 0.012 ms
day 3 0.011 ms 0.010 ms
day 4 0.020 ms 0.020 ms
day 5 0.024 ms 0.024 ms
day 6 0.004 ms 0.007 ms
day 7 0.018 ms 0.018 ms
day 8 0.044 ms 0.285 ms
day 9 0.191 ms 0.301 ms
day 10 0.002 ms 0.005 ms
day 11 0.010 ms 1.220 ms
day 12 0.511 ms 0.399 ms
day 13 0.026 ms 0.029 ms
day 14 0.067 ms 0.195 ms
day 15 0.005 ms 0.006 ms
day 16 11.45 ms 12.73 ms
day 17 0.164 ms 0.520 ms
day 18 0.168 ms 0.578 ms
day 19 3.20 ms 9.37 ms
day 20 3.66 ms 71.010 ms
day 21 0.101 ms 0.199 ms
day 22 0.085 ms 0.163 ms
day 23 0.619 ms 81.66 ms
day 24 13.14 ms 38.55 ms
day 25 0.008 ms Single mouse click
one-by-one (1 CPU core) parallel
everything 263.20 ms 132.64 ms

Run all solutions

I don't include input files because of https://old.reddit.com/r/adventofcode/wiki/faqs/copyright/inputs. This way the benchmarks are not completely reproducible, but I am not going publish a scientific paper anyway. Simply put your input files and run the project to see the solution appear.

# Run everything
cd ../runner
cargo +nightly run --release --bin runner

# 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

License

This project is released under the GNU GPL-3.0 license. Check out the LICENSE file for more information.