https://github.com/faern/adventofcode2016
My solutions to http://adventofcode.com/2016
https://github.com/faern/adventofcode2016
Last synced: about 1 year ago
JSON representation
My solutions to http://adventofcode.com/2016
- Host: GitHub
- URL: https://github.com/faern/adventofcode2016
- Owner: faern
- License: gpl-3.0
- Created: 2016-11-28T13:04:46.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-03T09:24:29.000Z (over 9 years ago)
- Last Synced: 2024-10-16T13:13:37.376Z (over 1 year ago)
- Language: Rust
- Size: 53.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Advent of Code 2016, faern's solutions
Here are my solutions built in Rust. The folder structure is as follows:
* `aoc/` - The CLI for the problem solver. Read below how to use it.
* `dayX/` - The crate containing the solution for dayX.
* `base/` - Some shared interfaces and utilities between the solutions and the
CLI. Such as the enum abstraction for a `Part` denoting if we are solving
part one or two on a given day.
## How to use
### Compile
* Get a working Rust environment. see https://rustup.rs/. Should work fine with
both stable and nightly.
* Cd into `aoc/`.
* Run `cargo build --release` to compile with optimizations.
### Run
* Run `./target/release/aoc --help` for help
* The flag `--day X` will select problem for day `X`
* The flag `--part Y` will select part `Y`, must be 1 or 2
* The flag `--input ` selects which problem input file to read from
#### Example usage
```
$ ./target/release/aoc --day 1 --part 1 --input inputs/1
Solution: 301
Time to solve: 130 us
```
### Benchmark
Since it might be interesting to know how fast the solution can be obtained
I added a benchmarking mode to the program.
#### Prerequisites
To get the benchmark feature one must have the nightly version of Rust and
build the `aoc` crate with the feature `bench`:
`cargo build --release --features "bench"`
Or if nightly is not your default toolchain:
`rustup run nightly cargo build --release --features "bench"`
#### Running benchmarks
It's as easy as adding the `--bench` flag to the run:
```
$ ./target/release/aoc --day 1 --part 1 --input inputs/1 --bench
21,765 ns/iter (+/- 2,916)
```