Skip to content

Commit

Permalink
Year 2018: Day 03
Browse files Browse the repository at this point in the history
  • Loading branch information
joshleaves committed Apr 17, 2024
1 parent 05914d2 commit 8def621
Show file tree
Hide file tree
Showing 8 changed files with 1,388 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Of note:
- The changelog 2015.5.2 has been rewritten from each commit content.
- This file may be amended entirely in the future to adhere to the [GNU Changelog style](https://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html#Style-of-Change-Logs)

## [2018.3.1]
### Added
- Solved [exercice for 2018, day 03](src/year_2018/03.rs).

## [2018.2.1]
### Added
- Solved [exercice for 2018, day 02](src/year_2018/02.rs).
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "advent-rs"
version = "2018.2.1"
version = "2018.3.1"
edition = "2021"
authors = ["Arnaud 'red' Rouyer"]
readme = "README.md"
Expand Down
4 changes: 4 additions & 0 deletions NOTES_2018.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ Again, first day is nothing to write home about: just iterate and sum, nothing t
## Day 02: Inventory Management System

Oh look, another of those "loop over EVERY-FUCKING-COMBINATION" exercises...

## Day 03: No Matter How You Slice It

Not much we haven't seen last year.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ I'm also adding notes that may be useful if you're (like me) discovering Rust:
- [2015, complete!](NOTES_2015.md)
- [2016, complete!](NOTES_2016.md)
- [2017, complete!](NOTES_2017.md)
- [2018, up to day 01!](NOTES_2018.md)
- [2018, up to day 03](NOTES_2018.md)

# Regarding style rules
I'm gonna use a mix of what `cargo fmt` does, with some stuff that feels more natural to me.
Expand Down
23 changes: 22 additions & 1 deletion benches/year_2018.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use advent_rs::year_2018::day_01;
use advent_rs::year_2018::day_02;
use advent_rs::year_2018::day_03;
use criterion::{black_box, criterion_group, criterion_main, Criterion};

fn year_2018_day_01(c: &mut Criterion) {
Expand Down Expand Up @@ -32,5 +33,25 @@ fn year_2018_day_02(c: &mut Criterion) {
g2018_day_02.finish();
}

criterion_group!(benches, year_2018_day_01, year_2018_day_02);
fn year_2018_day_03(c: &mut Criterion) {
let input = include_str!("../inputs/year_2018/day_03_input");
assert_eq!(day_03::day_03_v1(input), 101_565);
assert_eq!(day_03::day_03_v2(input), 656);

let mut g2018_day_03 = c.benchmark_group("year_2018::day_03");
g2018_day_03.bench_function("year_2018::day_03_v1", |b| {
b.iter(|| day_03::day_03_v1(black_box(input)))
});
g2018_day_03.bench_function("year_2018::day_03_v2", |b| {
b.iter(|| day_03::day_03_v2(black_box(input)))
});
g2018_day_03.finish();
}

criterion_group!(
benches,
year_2018_day_01,
year_2018_day_02,
year_2018_day_03
);
criterion_main!(benches);
Loading

0 comments on commit 8def621

Please sign in to comment.