Skip to content

Commit

Permalink
Year 2016: Day 06
Browse files Browse the repository at this point in the history
  • Loading branch information
joshleaves committed Mar 16, 2024
1 parent 9f1df42 commit 54e2508
Show file tree
Hide file tree
Showing 7 changed files with 684 additions and 7 deletions.
14 changes: 9 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,32 @@ 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)

## [2016.6.1]
### Added
- Solved [exercice for 2016, day 06](src/year_2016/day_06.rs).

## [2016.5.1]
### Added
- Solved [exercice for 2016, day 05](src/year_2015/day_05.rs).
- Solved [exercice for 2016, day 05](src/year_2016/day_05.rs).

## [2016.4.1]
### Added
- Solved [exercice for 2016, day 04](src/year_2015/day_04.rs).
- Solved [exercice for 2016, day 04](src/year_2016/day_04.rs).

## [2016.3.1]
### Added
- Solved [exercice for 2016, day 03](src/year_2015/day_03.rs).
- Solved [exercice for 2016, day 03](src/year_2016/day_03.rs).
- Added a [VSCode snipper](.vscode/new_day.code-snippets). May prove useful in setting up a new day file.

## [2016.2.1]
### Added
- Solved [exercice for 2016, day 02](src/year_2015/day_02.rs).
- Solved [exercice for 2016, day 02](src/year_2016/day_02.rs).
### Changed
- Moved all inputs from 2015 into their own folder (`inputs/year_2015`).

## [2016.1.1]
### Added
- Solved [exercice for 2016, day 01](src/year_2015/day_01.rs).
- Solved [exercice for 2016, day 01](src/year_2016/day_01.rs).
### Changed
- Moved old benches (`benches/advent-bench.rs`) into their own file (`benches/year_2015.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 = "2016.5.1"
version = "2016.6.1"
edition = "2021"
authors = ["Arnaud 'red' Rouyer"]
readme = "README.md"
Expand Down
4 changes: 4 additions & 0 deletions NOTES_2016.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ Interestingly, when calculating the checksum, it is FASTER to reiterate over the
Hey look, it's those pesky [MD5 hashes](https://en.wikipedia.org/wiki/MD5) again!

For efficiency purposes, the [MD5 crate that I am using](https://crates.io/crates/md-5) is returning hashes in their hexadecimal value, so when humans are expecting to get 32 characters, the digest is returned as 16 `u8` values (reminder, an `u8` goes from `0` to `255` so it can store `2 (* 16 = 256)` hexadecimal values). It's a bit of a mental gymnastic to juggle with afterwards, but it's not impossible either.

## Day 06: Signals and Noise

Playing with specific types for closures can be a pain, but it's often very funny to understand how things work under the hood.
16 changes: 15 additions & 1 deletion benches/year_2016.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use advent_rs::year_2016::day_02;
use advent_rs::year_2016::day_03;
use advent_rs::year_2016::day_04;
use advent_rs::year_2016::day_05;
use advent_rs::year_2016::day_06;
use criterion::{black_box, criterion_group, criterion_main, Criterion};

pub fn year_2016_day_01(c: &mut Criterion) {
Expand Down Expand Up @@ -65,12 +66,25 @@ pub fn year_2016_day_05(c: &mut Criterion) {
g2016_day_05.finish();
}

pub fn year_2016_day_06(c: &mut Criterion) {
let mut g2016_day_06 = c.benchmark_group("year_2016::day_06");
let input_year_2016_day_06 = include_str!("../inputs/year_2016/day_06_input");
g2016_day_06.bench_function("year_2016::day_06_v1", |b| {
b.iter(|| day_06::day_06_v1(black_box(input_year_2016_day_06)))
});
g2016_day_06.bench_function("year_2016::day_06_v2", |b| {
b.iter(|| day_06::day_06_v2(black_box(input_year_2016_day_06)))
});
g2016_day_06.finish();
}

criterion_group!(
benches,
year_2016_day_01,
year_2016_day_02,
year_2016_day_03,
year_2016_day_04,
year_2016_day_05
year_2016_day_05,
year_2016_day_06
);
criterion_main!(benches);
Loading

0 comments on commit 54e2508

Please sign in to comment.