Skip to content

Commit

Permalink
Year 2018: Day 02
Browse files Browse the repository at this point in the history
  • Loading branch information
joshleaves committed Apr 16, 2024
1 parent 20a4938 commit 05914d2
Show file tree
Hide file tree
Showing 7 changed files with 377 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ 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.2.1]
### Added
- Solved [exercice for 2018, day 02](src/year_2018/02.rs).

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


## [2017.25.1]
### Added
- Solved [exercice for 2017, day 23](src/year_2017/23.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.1.1"
version = "2018.2.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 @@ -2,3 +2,7 @@
## Day 01: Chronal Calibration

Again, first day is nothing to write home about: just iterate and sum, nothing too complicated.

## Day 02: Inventory Management System

Oh look, another of those "loop over EVERY-FUCKING-COMBINATION" exercises...
18 changes: 17 additions & 1 deletion benches/year_2018.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use advent_rs::year_2018::day_01;
use advent_rs::year_2018::day_02;
use criterion::{black_box, criterion_group, criterion_main, Criterion};

fn year_2018_day_01(c: &mut Criterion) {
Expand All @@ -16,5 +17,20 @@ fn year_2018_day_01(c: &mut Criterion) {
g2018_day_01.finish();
}

criterion_group!(benches, year_2018_day_01);
fn year_2018_day_02(c: &mut Criterion) {
let input = include_str!("../inputs/year_2018/day_02_input");
assert_eq!(day_02::day_02_v1(input), "7872");
assert_eq!(day_02::day_02_v2(input), "tjxmoewpdkyaihvrndfluwbzc");

let mut g2018_day_02 = c.benchmark_group("year_2018::day_02");
g2018_day_02.bench_function("year_2018::day_02_v1", |b| {
b.iter(|| day_02::day_02_v1(black_box(input)))
});
g2018_day_02.bench_function("year_2018::day_02_v2", |b| {
b.iter(|| day_02::day_02_v2(black_box(input)))
});
g2018_day_02.finish();
}

criterion_group!(benches, year_2018_day_01, year_2018_day_02);
criterion_main!(benches);
250 changes: 250 additions & 0 deletions inputs/year_2018/day_02_input
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
tjxmoewpqkyaiqvmndgflunszc
tjxmobwpqkyaihvrndgfjubszm
tjxmzewpqkyaihvrydgflrbszc
tjxmoeypqkyvihvrndgflubsza
tjcmoewpqkytihvrndgflgbszc
tjvmoewpqkyanevrndgflubszc
tjxmoewpqkdiihirndgflubszc
tjxboewpqkyaihbrnogflubszc
ojpmoewpqkyaihvjndgflubszc
tjxyoewpqkyaiuvrndgflutszc
tjxmoewpqkyalhvrndmflebszc
tjxmoewpqzyaihhrndgflubszf
tjxmrewpqkyaihirndgfjubszc
pjxmoewpqkyaihvendgfbubszc
txxmkewpqkyjihvrndgflubszc
tjxmoewcqkyaihvrnmgflubczc
tjxmoewkqkyaghvrndgfluvszc
tjxmoewfqkhaihvrndgflubhzc
jjqmoewpqkyaihvrndzflubszc
tjxmoewmqksaihvcndgflubszc
tjrmoewpqkyaihvrvdgflubzzc
tjxxoewpqkyaiiwrndgflubszc
cjxmoawxqkyaihvrndgflubszc
tjxdoewpvkyaihvrndgflubsoc
tjxmsewpqkyaihvrndgfluzozc
tjxmoewpqkyafhvrnyeflubszc
tjxmlewpqkyawhvondgflubszc
tjxmonwpqkyaiqvrnxgflubszc
tjxmoewcqkyaihvrnjgflumszc
tjvmoewpqkyaihveadgflubszc
tjxmogfpqkyaigvrndgflubszc
tybmoewpqkyaihvrndgllubszc
tjxmoewpdkyaihvrndgfluwbzc
etxmbewpqkyaihvrndgflubszc
tjxmoeapqcynihvrndgflubszc
tbxmoewpqkyaihvrndgfdebszc
haxmoewpqyyaihvrndgflubszc
ojxmoewpqkyaihvrnegflubszr
tjxmoewpqkyaihvrndoflubarc
ljxmoewpqkykihvrndgflvbszc
tjxmovwpqkyaihvrndgfluzsyc
tvxmoewpqkyanhvrkdgflubszc
tjxmoewpqkyaihkrndgfluwwzc
zjxmoewpfkyaihvrndgfrubszc
tjxyoegpqkyaihvrndlflubszc
tjxmoewpqkyamhvrnsgflubmzc
tjmmoewpqkyaihvrndgftuwszc
tjxmoewpqbraihvrncgflubszc
tjxmeeepqkyainvrndgflubszc
tjemoegpqkyaihvredgflubszc
tjxmoewpqkyaihvdndgfzubqzc
tjxmoegrqkyaihfrndgflubszc
tjxmoewpqxyaihvrndgfluyvzc
qjxmoewpqkyaiwvrnfgflubszc
tjxwoewpqkyashkrndgflubszc
tjzmoewiqkyaihurndgflubszc
tjumuewpqkyaihvrndgflubssc
tyxooewpukyaihvrndgflubszc
tjxvoewpqkyaiivindgflubszc
ijxmoqwpqkyaihvradgflubszc
tjxmlewpqkyaihvrhdgflubwzc
tjxmkewpqkyajhqrndgflubszc
tjxmoewpqkqaiherndgflurszc
tjamoewpqkyaizvondgflubszc
tjxgogwpqkyalhvrndgflubszc
tjxmoewpqkyachvrndgflubuzq
tjxmowqpqkyaihvrnegflubszc
mjxmoewpwkyaihvrndgfkubszc
tpbmoewpqkyaihvrzdgflubszc
tjbmoewpqkyaiuvrndgflsbszc
tjxmoewpqklaghvrndgflubazc
tjxmoewpqkyrihvrndgwlpbszc
tjcmoewpqksaiyvrndgflubszc
tjxmoeapqkymihvindgflubszc
tjxmdewpqkyafhvrndgflqbszc
tjxmoewpqxyaihvrndsflubszi
tjxmoeppqkyaihvrcdgflubszd
tjxmomwpqkyainvrmdgflubszc
tjxmovwpqkyaihvrndgfdubdzc
tjxmoewwqkiaihvrjdgflubszc
tmxmoewpqkyaifvrndgflubszs
tbxmoewpqkyaihvrbdgflunszc
tjxmoewrqkyaihvxndgflubszp
ujxmoewpqkyaihvxndgflubpzc
tdxmotwpqkyaihvdndgflubszc
tjxmvewpqkyaihfrndgtlubszc
tjfmoewpqkyaihvrnyqflubszc
tjxfolwzqkyaihvrndgflubszc
ojrmoiwpqkyaihvrndgflubszc
tjsmoqwpqkyqihvrndgflubszc
tjxmohwpqkyaihvrudgflubslc
tjxtoiwpqkyaihvrnogflubszc
taxmoewpqkyaiyvrndgfwubszc
tjxwnezpqkyaihvrndgflubszc
tjxmyevpqkyaivvrndgflubszc
tjxdoeopqkyaihvgndgflubszc
tjxaoewpqkmaihvrndgflufszc
tjxmoewpqkyaxhvrndgflubncc
tjxmoewpqkyaihurndgflubbjc
tjxmjewpqgyaihvrnngflubszc
tjxmogwpqkyaihvrndgflubbcc
tjxmoewplkyaihvrnpgflibszc
tjwmoewpqkyaohvrndgfbubszc
tjwmoewpqkyaihvrndgfsubszm
tjxmogwpqkyaihvrndiflubqzc
tjxmoewpqkyaihvrndgflopshc
rjxmlewpvkyaihvrndgflubszc
tjxmogwpakyaihvrndgflzbszc
tjxmoeppqkyaihvrndgflmxszc
tjxmoewpqkyhihgrndgfzubszc
tjxqoewpqkyaihtrndgwlubszc
tjxnoespqkyaihvrndgflubsuc
tjmmoewpqkraihvrndgflfbszc
tjxmoewnqkwaihvrndgflubstc
tjxmoewpqqyaihvrndgfljbszi
tjxmoewpqkyaihkrkdgalubszc
tjxmoewpqkyaihvradgjlurszc
tvxmoewpqkybihvrndbflubszc
tjxvoewpqkyaihvradgfoubszc
tjxmoewpqfyaihvlodgflubszc
tjxmoewmnkyaiivrndgflubszc
kjxmoewpqkyaihprndgflcbszc
hjxmoewpqkcaihvrndgvlubszc
tjxmoewcqkyaihvrncgfllbszc
tuxmoewpckyaihvrndoflubszc
tjxmdewpokyaihvrndgflubszn
mjxmaewpqkyaqhvrndgflubszc
tjxmoewpmzyaihvrndgfiubszc
tjxmoewnqkyvihvrndgflubszk
tjxmoewpmnyaihvrndgftubszc
zjxmoewpqkysihvrndgfmubszc
tjxmoewpqkyaihzrntgflubbzc
tjxmoewpqkgaihwrndsflubszc
tjxjoewpqkyaihvrndgflgbizc
oqxmoewpqkyaihvrndgfldbszc
wjamoewpqkyaihvfndgflubszc
tjxmoewtmkyvihvrndgflubszc
tjlmojwpqkyaihvrndgfludszc
tjxmowwpqkyaihvrndefludszc
tjxmoewpqkbaihvrndgfluaszt
tjxmoewpqkzaahvrodgflubszc
tjxmoewpqkgaihvrndgflubtpc
tjxmoenpqkyaihcrndgfqubszc
tbxmoewpqbyaihvrndgalubszc
tjvmoewqqkyaihvrndvflubszc
tjxmoewpqkeaihvundgfaubszc
txxmoewpqkyaihvrwdgflpbszc
tzxmoewpqkijihvrndgflubszc
tjxmoewoqkytiuvrndgflubszc
tjxmrejplkyaihvrndgflubszc
tjxmoewpqkynihvrpxgflubszc
tjxmoewpqkvanhvrndgvlubszc
tjxmoewpdkyiihvrndgflubszs
tpxmyewpqkyaihvrndgfeubszc
tpxmoewpqyyaihvrndhflubszc
tjsmoewpqkyaihvrndhflubnzc
tjxmoewpukyaihvrnmgflubwzc
txxmoewpqlyaihwrndgflubszc
tjxmoewprkyaiovrndgflubxzc
tjxmouwpqkyaihzrodgflubszc
tjxmojwpqkywimvrndgflubszc
tjxsoewpqkyaihvrzdgqlubszc
tfxmoewpakyaihvrndgllubszc
tjhmoewpqiyaihvrndgflubsac
tjxmoewpqkoaihvrndoflubsxc
tjxmoewpqkyzpjvrndgflubszc
tjxmoewpqkyaiharndgzlnbszc
tjimoevpqkyaihvrndgflubbzc
tjxsoewpqkyahhvrndgfzubszc
txxmoewpqkyaimvrrdgflubszc
tjxmoewpwkyaihvrndpylubszc
tjxmoewpskyaghvrndgfbubszc
tjxmuewpqmyaihvrndgfyubszc
tjxmoewpqkyaihvdndgglubsxc
xjxmoewpqkyjiovrndgflubszc
gjxmoewpqkyaihvrndodlubszc
tjbmoewpqkyaihvridgflvbszc
tjxmozwpqkyapbvrndgflubszc
tjxeoewpqkyqihvrndgflubhzc
tjxdoewpqzyaihvrndgflubsmc
tjxmwewpqkyathvcndgflubszc
tjxmoewpszyaihvrndgflusszc
tuxmoewpqkyaihvrndgfluasxc
tjemoewpnvyaihvrndgflubszc
tjxmoewpjkyaihvrndgjlufszc
tjomoewppkyaihvzndgflubszc
tjxmvewpqkyaimvrntgflubszc
rjxmoewpqkyaihvpndgflubszq
hjxzoewpqkyaihvridgflubszc
texmoejpqkyaihvrndgflubszx
tjxcoewpqkyaihbrxdgflubszc
tjxmoewpnkyaihvrndgfltbsze
tjxmoewpdkyaihvrndwfluwbzc
tjxmoewpqryjihkrndgflubszc
tjlmoewpqkhaihvrndgflubsnc
tjxmovapqkjaihvrndgflubszc
tjxvoewpqkyaihqrndgfluyszc
tjxwoewnqkyaihvrndgfgubszc
tjdmoewpqklaihvcndgflubszc
tjxmoewpvkynihvrndgflubskc
tjxmtewpqkyaihvhndgfluaszc
tjxmoewpqkyanhvrnpgfluvszc
tjxmoewpqkyaifvbndgflubspc
tjxmoexpqknaihvrndgxlubszc
qjxmoewqqkyaihvrndgflubpzc
tjxmoewppkyaihvaxdgflubszc
myxmoewpqkyaihvrudgflubszc
tjxmwewpmkyaihvrndgflubssc
tjxmoewpqkyaihvrndgfxqbszq
tjxmoewhqkyaahvrndgflubbzc
tbxmoewmqkyaihvrndgflubszu
toxmolwpqkyaihvrndnflubszc
tjxmoewhqkyaihvrnrgflubvzc
yjxmoewcqkyaihvrndgflubfzc
tjxmoewpqkyamhvrgdgflmbszc
tjxmtewpqkyaizvrndgfluoszc
tjxmoewpqzyaihvrntsflubszc
fjxmoewpqkyaihyrmdgflubszc
tjxwoewpqcyaihbrndgflubszc
tjxmoebpqkzaihvrndcflubszc
tjxmoewpqkyaihvrndnlmubszc
tjxmoewpqkyaihvrndgeyubskc
tfxmoewpqryaihvrndgfluiszc
tjxmoewpqkjaihvynngflubszc
tjxmoewpqkqaihvonjgflubszc
tjfmokwpqkyeihvrndgflubszc
djxmoewpkkyaihvrnmgflubszc
tjxmiewpqkyaihvrndgflubhlc
tjxmmejpqkyaihvrnhgflubszc
djxmoewmqkyaihvrnggflubszc
tjxmoewpqkyaihvrkggflubsze
gjxmoewpqkyaihjrndgflvbszc
tjxmoewpqkyaidvrndgkzubszc
tjxmoewpqkyaedvrnpgflubszc
sjxmoewpqkyaihvrnngfluhszc
tjxmoewpqkuaihvrndghlubxzc
tjxmoewgqkyuihvrndgftubszc
tjxmoewpqsyaifvrkdgflubszc
tjxrrewpqkyaihvrnpgflubszc
tjxmoezpqkyaihvrwdgflabszc
tjfmoewpqknaihvrndgflubkzc
tjxmoewnqkxaihvrndgflubtzc
tjxmoewpkkyaihvrndgfrnbszc
tjxmorwpnkqaihvrndgflubszc
tsxmoewwqkyathvrndgflubszc
tjxmoeupqkyaihvrndyflubszp
bjxmoewdqkyaihvrndgflurszc
tjxmoewpvkyaihvrndoflubszq
sjxmoewpqkyaihvrndgflubyec
tjxmoewpqkyaizcrndgfnubszc
13 changes: 11 additions & 2 deletions src/year_2018.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! Year 2017
//! Year 2018
//!
#![doc = include_str!("../NOTES_2017.md")]
#![doc = include_str!("../NOTES_2018.md")]

pub mod day_01;
pub mod day_02;

pub fn solve(day: u8, part: u8, input: impl Into<String>) -> Option<String> {
if part > 2 {
Expand All @@ -11,6 +12,7 @@ pub fn solve(day: u8, part: u8, input: impl Into<String>) -> Option<String> {

match day {
1 => Some(day_01::day_01(part, input).to_string()),
2 => Some(day_02::day_02(part, input).to_string()),
_ => None,
}
}
Expand All @@ -25,4 +27,11 @@ mod tests {
assert_eq!(day_01::day_01_v1(input), 484);
assert_eq!(day_01::day_01_v2(input), 367);
}

#[test]
fn day_02() {
let input = include_str!("../inputs/year_2018/day_02_input");
assert_eq!(day_02::day_02_v1(input), "7872");
assert_eq!(day_02::day_02_v2(input), "tjxmoewpdkyaihvrndfluwbzc");
}
}
Loading

0 comments on commit 05914d2

Please sign in to comment.