432 stable releases

Uses new Rust 2021

new 2022.0.6 Dec 7, 2022
2019.12.480 Dec 5, 2022
2019.12.470 Nov 23, 2022
2019.12.447 Jul 23, 2022
2019.12.168 Nov 30, 2020

#135 in Rust patterns

Download history 12/week @ 2022-08-17 757/week @ 2022-08-24 47/week @ 2022-08-31 1260/week @ 2022-09-07 439/week @ 2022-09-14 4/week @ 2022-09-21 111/week @ 2022-09-28 21/week @ 2022-10-05 28/week @ 2022-10-12 85/week @ 2022-10-19 29/week @ 2022-10-26 972/week @ 2022-11-02 33/week @ 2022-11-09 173/week @ 2022-11-16 35/week @ 2022-11-23 252/week @ 2022-11-30

501 downloads per month

MIT license

1MB
22K SLoC

Crates.io Docker Hub codecov

Advent of Code solutions

Solutions to Advent of Code problems in Rust.

Running locally

The command line tool takes <year> <day> <part> as arguments and reads the problem input from stdin:

$ echo 14 | cargo run -q 2019 1 1
2

Published crate

This crate is published to crates.io/crates/advent-of-code.

As a library it exposes a solve(year, day, part, input) function as documented on docs.rs/advent-of-code:

// Using the dependency added: advent-of-code = "*":
use advent_of_code::solve;

fn main() {
    assert_eq!(solve(2019, 1, 1, "14"), Ok("2".to_string()));
}

It also contains the command line program to run the solution:

$ cargo install advent-of-code
$ echo 14 | advent-of-code 2019 1 1
2

Docker image on Docker Hub

The command line interface is published to a fredrikfornwall/advent-of-code Docker image:

$ docker pull fredrikfornwall/advent-of-code:latest
$ echo 14 | docker run -i fredrikfornwall/advent-of-code:latest 2019 1 1
2

Generating flamegraphs on macOS

Install flamegraph with cargo install flamegraph and build a benchmark binary with:

RUSTFLAGS='-g' cargo build --release --bench benchmark

This will create a benchmark binary under something like ls ../../target/release/deps/benchmark-31ba773f80f7f5d8. Then profile and generate a flamegraph.svg by running

sudo flamegraph ../../target/release/deps/benchmark-31ba773f80f7f5d8  --bench 2020_07_1

Dependencies