Skip to content

Commit

Permalink
Year 2018: Day 04
Browse files Browse the repository at this point in the history
  • Loading branch information
joshleaves committed Apr 18, 2024
1 parent 8def621 commit 7c64d37
Show file tree
Hide file tree
Showing 8 changed files with 1,266 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.4.1]
### Added
- Solved [exercice for 2018, day 04](src/year_2018/04.rs).

## [2018.3.1]
### Added
- Solved [exercice for 2018, day 03](src/year_2018/03.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.3.1"
version = "2018.4.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 @@ -10,3 +10,7 @@ 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.

## Day 04: Repose Record

There's something about this "find the most used record" type of exercises that I dislike.
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 03](NOTES_2018.md)
- [2018, up to day 04](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
19 changes: 18 additions & 1 deletion benches/year_2018.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use advent_rs::year_2018::day_01;
use advent_rs::year_2018::day_02;
use advent_rs::year_2018::day_03;
use advent_rs::year_2018::day_04;
use criterion::{black_box, criterion_group, criterion_main, Criterion};

fn year_2018_day_01(c: &mut Criterion) {
Expand Down Expand Up @@ -48,10 +49,26 @@ fn year_2018_day_03(c: &mut Criterion) {
g2018_day_03.finish();
}

fn year_2018_day_04(c: &mut Criterion) {
let input = include_str!("../inputs/year_2018/day_04_input");
assert_eq!(day_04::day_04_v1(input), 35_623);
assert_eq!(day_04::day_04_v2(input), 23_037);

let mut g2018_day_04 = c.benchmark_group("year_2018::day_04");
g2018_day_04.bench_function("year_2018::day_04_v1", |b| {
b.iter(|| day_04::day_04_v1(black_box(input)))
});
g2018_day_04.bench_function("year_2018::day_04_v2", |b| {
b.iter(|| day_04::day_04_v2(black_box(input)))
});
g2018_day_04.finish();
}

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

0 comments on commit 7c64d37

Please sign in to comment.