273 stable releases

new 2019.12.322 May 5, 2021
2019.12.317 Apr 28, 2021
2019.12.284 Mar 29, 2021
2019.12.265 Dec 31, 2020
2019.12.168 Nov 30, 2020

#73 in Rust patterns

Download history 189/week @ 2021-01-13 5/week @ 2021-01-20 5/week @ 2021-01-27 25/week @ 2021-02-03 532/week @ 2021-02-10 675/week @ 2021-02-17 17/week @ 2021-02-24 236/week @ 2021-03-03 26/week @ 2021-03-10 51/week @ 2021-03-17 637/week @ 2021-03-24 244/week @ 2021-03-31 442/week @ 2021-04-07 573/week @ 2021-04-14 462/week @ 2021-04-21 125/week @ 2021-04-28

1,356 downloads per month

MIT license

785KB
18K 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