Crates.io | advent-of-code |
lib.rs | advent-of-code |
version | 2022.0.66 |
source | src |
created_at | 2020-09-10 20:07:00.422103 |
updated_at | 2024-02-25 00:52:16.675134 |
description | Solutions to Advent of Code |
homepage | https://github.com/fornwall/advent-of-code |
repository | https://github.com/fornwall/advent-of-code |
max_upload_size | |
id | 287145 |
size | 3,694,613 |
Solutions to Advent of Code problems in Rust.
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
The command-line tool can be installed as a brew tap:
$ brew install fornwall/tap/advent-of-code
$ echo 14 | advent-of-code 2019 1 1
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
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
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