Missed several updates. Working on 8 pt 2
This commit is contained in:
@@ -10,40 +10,40 @@ use nom::{
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Card {
|
pub struct Card {
|
||||||
winning_set: Vec<u32>,
|
winning_set: Vec<u64>,
|
||||||
player_set: Vec<u32>,
|
player_set: Vec<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Card {
|
impl Card {
|
||||||
fn score(&self) -> u32 {
|
fn score(&self) -> u64 {
|
||||||
let count = self.win_count();
|
let count = self.win_count();
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
2_u32.pow(count as u32 - 1)
|
2_u64.pow(count as u64 - 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn win_count(&self) -> u32 {
|
fn win_count(&self) -> u64 {
|
||||||
self.player_set.iter().filter(|num| {self.winning_set.contains(num)}).count() as u32
|
self.player_set.iter().filter(|num| {self.winning_set.contains(num)}).count() as u64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53
|
// Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53
|
||||||
fn parse_line(input: &str) -> IResult<&str, Card> {
|
fn parse_line(input: &str) -> IResult<&str, Card> {
|
||||||
let (input, _) = preceded(tag("Card "), preceded(space0, complete::u32))(input)?;
|
let (input, _) = preceded(tag("Card "), preceded(space0, complete::u64))(input)?;
|
||||||
let (input, winning_set) = preceded(tag(": "), preceded(space0, separated_list1(space1, complete::u32)))(input)?;
|
let (input, winning_set) = preceded(tag(": "), preceded(space0, separated_list1(space1, complete::u64)))(input)?;
|
||||||
let (input, player_set) = preceded(tag(" | "), preceded(space0, separated_list1(space1, complete::u32)))(input)?;
|
let (input, player_set) = preceded(tag(" | "), preceded(space0, separated_list1(space1, complete::u64)))(input)?;
|
||||||
Ok((input, Card{winning_set, player_set}))
|
Ok((input, Card{winning_set, player_set}))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn part1(input: &str) -> String {
|
pub fn part1(input: &str) -> String {
|
||||||
input.lines().map(|line| { parse_line(line).unwrap().1.score() }).sum::<u32>().to_string()
|
input.lines().map(|line| { parse_line(line).unwrap().1.score() }).sum::<u64>().to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn part2(input: &str) -> String {
|
pub fn part2(input: &str) -> String {
|
||||||
let num_games = input.lines().count();
|
let num_games = input.lines().count();
|
||||||
let mut current_cards = (0..num_games).map(|_| {1}).collect::<Vec<u32>>();
|
let mut current_cards = (0..num_games).map(|_| {1}).collect::<Vec<u64>>();
|
||||||
current_cards.push(0);
|
current_cards.push(0);
|
||||||
let mut current_index = 0;
|
let mut current_index = 0;
|
||||||
let mut cards = input.lines().map(|line| {
|
let mut cards = input.lines().map(|line| {
|
||||||
@@ -58,7 +58,7 @@ pub fn part2(input: &str) -> String {
|
|||||||
current_cards[i] += number_of_current_card;
|
current_cards[i] += number_of_current_card;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current_cards.into_iter().sum::<u32>().to_string()
|
current_cards.into_iter().sum::<u64>().to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
|
|||||||
639
day_06/Cargo.lock
generated
Normal file
639
day_06/Cargo.lock
generated
Normal file
@@ -0,0 +1,639 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aho-corasick"
|
||||||
|
version = "1.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anes"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atty"
|
||||||
|
version = "0.2.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||||
|
dependencies = [
|
||||||
|
"hermit-abi",
|
||||||
|
"libc",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "1.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.14.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cast"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926"
|
||||||
|
dependencies = [
|
||||||
|
"ciborium-io",
|
||||||
|
"ciborium-ll",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium-io"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium-ll"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b"
|
||||||
|
dependencies = [
|
||||||
|
"ciborium-io",
|
||||||
|
"half",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap"
|
||||||
|
version = "3.2.25"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"clap_lex",
|
||||||
|
"indexmap",
|
||||||
|
"textwrap",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_lex"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
|
||||||
|
dependencies = [
|
||||||
|
"os_str_bytes",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "criterion"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb"
|
||||||
|
dependencies = [
|
||||||
|
"anes",
|
||||||
|
"atty",
|
||||||
|
"cast",
|
||||||
|
"ciborium",
|
||||||
|
"clap",
|
||||||
|
"criterion-plot",
|
||||||
|
"itertools",
|
||||||
|
"lazy_static",
|
||||||
|
"num-traits",
|
||||||
|
"oorandom",
|
||||||
|
"plotters",
|
||||||
|
"rayon",
|
||||||
|
"regex",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
"serde_json",
|
||||||
|
"tinytemplate",
|
||||||
|
"walkdir",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "criterion-plot"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
|
||||||
|
dependencies = [
|
||||||
|
"cast",
|
||||||
|
"itertools",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-deque"
|
||||||
|
version = "0.8.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"crossbeam-epoch",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-epoch"
|
||||||
|
version = "0.9.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"cfg-if",
|
||||||
|
"crossbeam-utils",
|
||||||
|
"memoffset",
|
||||||
|
"scopeguard",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-utils"
|
||||||
|
version = "0.8.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "day_06"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"criterion",
|
||||||
|
"nom",
|
||||||
|
"strum",
|
||||||
|
"strum_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "either"
|
||||||
|
version = "1.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "half"
|
||||||
|
version = "1.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.12.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "heck"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hermit-abi"
|
||||||
|
version = "0.1.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "indexmap"
|
||||||
|
version = "1.9.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"hashbrown",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itertools"
|
||||||
|
version = "0.10.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "1.0.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.66"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca"
|
||||||
|
dependencies = [
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lazy_static"
|
||||||
|
version = "1.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.150"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.6.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memoffset"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "minimal-lexical"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nom"
|
||||||
|
version = "7.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
"minimal-lexical",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.18.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "oorandom"
|
||||||
|
version = "11.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "os_str_bytes"
|
||||||
|
version = "6.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
"plotters-backend",
|
||||||
|
"plotters-svg",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters-backend"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters-svg"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab"
|
||||||
|
dependencies = [
|
||||||
|
"plotters-backend",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.70"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.33"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rayon"
|
||||||
|
version = "1.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
"rayon-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rayon-core"
|
||||||
|
version = "1.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-deque",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex"
|
||||||
|
version = "1.10.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-automata",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-automata"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-syntax"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "same-file"
|
||||||
|
version = "1.0.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scopeguard"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.193"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.193"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.108"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strum"
|
||||||
|
version = "0.25.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strum_macros"
|
||||||
|
version = "0.25.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0"
|
||||||
|
dependencies = [
|
||||||
|
"heck",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"rustversion",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.39"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "textwrap"
|
||||||
|
version = "0.16.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tinytemplate"
|
||||||
|
version = "1.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "walkdir"
|
||||||
|
version = "2.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
|
||||||
|
dependencies = [
|
||||||
|
"same-file",
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-backend"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"log",
|
||||||
|
"once_cell",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-backend",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "web-sys"
|
||||||
|
version = "0.3.66"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f"
|
||||||
|
dependencies = [
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-i686-pc-windows-gnu",
|
||||||
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-util"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
22
day_06/Cargo.toml
Normal file
22
day_06/Cargo.toml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
[package]
|
||||||
|
name = "day_06"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
nom = "7.1.3"
|
||||||
|
strum = "0.25.0"
|
||||||
|
strum_macros = "0.25.3"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
criterion = { version = "0.4", features = ["html_reports"] }
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "part1"
|
||||||
|
harness = false
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "part2"
|
||||||
|
harness = false
|
||||||
11
day_06/benches/part1.rs
Normal file
11
day_06/benches/part1.rs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
|
use day_06::prelude::*;
|
||||||
|
|
||||||
|
fn criterion_benchmark(c: &mut Criterion) {
|
||||||
|
let input = include_str!("../input.txt");
|
||||||
|
c.bench_function("part 1", |b| b.iter(|| part1(black_box(input))));
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
criterion_main!(benches);
|
||||||
11
day_06/benches/part2.rs
Normal file
11
day_06/benches/part2.rs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
|
use day_06::prelude::*;
|
||||||
|
|
||||||
|
fn criterion_benchmark(c: &mut Criterion) {
|
||||||
|
let input = include_str!("../input.txt");
|
||||||
|
c.bench_function("part 2", |b| b.iter(|| part2(black_box(input))));
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
criterion_main!(benches);
|
||||||
2
day_06/input.txt
Normal file
2
day_06/input.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Time: 46 82 84 79
|
||||||
|
Distance: 347 1522 1406 1471
|
||||||
64
day_06/src/lib.rs
Normal file
64
day_06/src/lib.rs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
use nom::{
|
||||||
|
bytes::complete::tag,
|
||||||
|
character::complete::{
|
||||||
|
self, space0, space1,
|
||||||
|
},
|
||||||
|
multi::separated_list1,
|
||||||
|
sequence::{preceded, tuple},
|
||||||
|
IResult,
|
||||||
|
};
|
||||||
|
use std::iter::zip;
|
||||||
|
|
||||||
|
fn parse_races(input: &str) -> IResult<&str, Vec<(u64, u64)>> {
|
||||||
|
let (input, times) = preceded(tuple((tag("Time:"),space1)), separated_list1(space1, complete::u64))(input)?;
|
||||||
|
let (input, distances) = preceded(tuple((tag("\nDistance:"),space1)), separated_list1(space1, complete::u64))(input)?;
|
||||||
|
Ok((input, zip(times, distances).collect()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_races_alt(input: &str) -> IResult<&str, (u64, u64)> {
|
||||||
|
let (input, times) = preceded(tuple((tag("Time:"),space0)), complete::u64)(input)?;
|
||||||
|
let (input, distances) = preceded(tuple((tag("\nDistance:"),space0)), complete::u64)(input)?;
|
||||||
|
Ok((input, (times, distances)))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn part1(input: &str) -> String {
|
||||||
|
let (_, races) = parse_races(input).unwrap();
|
||||||
|
races.into_iter().map(|(time, distance)| {
|
||||||
|
let upper_bound_full = (time as f64 + ((time as f64).powi(2) - 4.0 * distance as f64).sqrt()) / 2.0;
|
||||||
|
let upper_bound = if upper_bound_full - upper_bound_full.floor() == 0.0 {
|
||||||
|
upper_bound_full.floor() as u64 - 1
|
||||||
|
} else {
|
||||||
|
upper_bound_full.floor() as u64
|
||||||
|
};
|
||||||
|
let lower_bound_full = (time as f64 - ((time as f64).powi(2) - 4.0 * distance as f64).sqrt()) / 2.0;
|
||||||
|
let lower_bound = if lower_bound_full - lower_bound_full.ceil() == 0.0 {
|
||||||
|
lower_bound_full.ceil() as u64 + 1
|
||||||
|
} else {
|
||||||
|
lower_bound_full.ceil() as u64
|
||||||
|
};
|
||||||
|
upper_bound - lower_bound + 1
|
||||||
|
}).product::<u64>().to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn part2(input: &str) -> String {
|
||||||
|
let (_, (time, distance)) = parse_races_alt(input.replace(" ", "").as_str()).unwrap();
|
||||||
|
let upper_bound_full = (time as f64 + ((time as f64).powi(2) - 4.0 * distance as f64).sqrt()) / 2.0;
|
||||||
|
let upper_bound = if upper_bound_full - upper_bound_full.floor() == 0.0 {
|
||||||
|
upper_bound_full.floor() as u64 - 1
|
||||||
|
} else {
|
||||||
|
upper_bound_full.floor() as u64
|
||||||
|
};
|
||||||
|
let lower_bound_full = (time as f64 - ((time as f64).powi(2) - 4.0 * distance as f64).sqrt()) / 2.0;
|
||||||
|
let lower_bound = if lower_bound_full - lower_bound_full.ceil() == 0.0 {
|
||||||
|
lower_bound_full.ceil() as u64 + 1
|
||||||
|
} else {
|
||||||
|
lower_bound_full.ceil() as u64
|
||||||
|
};
|
||||||
|
(upper_bound - lower_bound + 1).to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod prelude {
|
||||||
|
pub use super::part1;
|
||||||
|
pub use super::part2;
|
||||||
|
}
|
||||||
|
|
||||||
27
day_06/src/main.rs
Normal file
27
day_06/src/main.rs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
use day_06::prelude::*;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let input = include_str!("../input.txt");
|
||||||
|
println!("{}", part1(input));
|
||||||
|
println!("{}", part2(input));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part1() {
|
||||||
|
let test_input = "Time: 7 15 30
|
||||||
|
Distance: 9 40 200";
|
||||||
|
assert_eq!(part1(test_input), "288".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part2() {
|
||||||
|
let test_input = "Time: 7 15 30
|
||||||
|
Distance: 9 40 200";
|
||||||
|
assert_eq!(part2(test_input), "71503".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
639
day_07/Cargo.lock
generated
Normal file
639
day_07/Cargo.lock
generated
Normal file
@@ -0,0 +1,639 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aho-corasick"
|
||||||
|
version = "1.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anes"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atty"
|
||||||
|
version = "0.2.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||||
|
dependencies = [
|
||||||
|
"hermit-abi",
|
||||||
|
"libc",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "1.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.14.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cast"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926"
|
||||||
|
dependencies = [
|
||||||
|
"ciborium-io",
|
||||||
|
"ciborium-ll",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium-io"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium-ll"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b"
|
||||||
|
dependencies = [
|
||||||
|
"ciborium-io",
|
||||||
|
"half",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap"
|
||||||
|
version = "3.2.25"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"clap_lex",
|
||||||
|
"indexmap",
|
||||||
|
"textwrap",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_lex"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
|
||||||
|
dependencies = [
|
||||||
|
"os_str_bytes",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "criterion"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb"
|
||||||
|
dependencies = [
|
||||||
|
"anes",
|
||||||
|
"atty",
|
||||||
|
"cast",
|
||||||
|
"ciborium",
|
||||||
|
"clap",
|
||||||
|
"criterion-plot",
|
||||||
|
"itertools",
|
||||||
|
"lazy_static",
|
||||||
|
"num-traits",
|
||||||
|
"oorandom",
|
||||||
|
"plotters",
|
||||||
|
"rayon",
|
||||||
|
"regex",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
"serde_json",
|
||||||
|
"tinytemplate",
|
||||||
|
"walkdir",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "criterion-plot"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
|
||||||
|
dependencies = [
|
||||||
|
"cast",
|
||||||
|
"itertools",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-deque"
|
||||||
|
version = "0.8.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"crossbeam-epoch",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-epoch"
|
||||||
|
version = "0.9.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"cfg-if",
|
||||||
|
"crossbeam-utils",
|
||||||
|
"memoffset",
|
||||||
|
"scopeguard",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-utils"
|
||||||
|
version = "0.8.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "day_07"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"criterion",
|
||||||
|
"nom",
|
||||||
|
"strum",
|
||||||
|
"strum_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "either"
|
||||||
|
version = "1.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "half"
|
||||||
|
version = "1.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.12.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "heck"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hermit-abi"
|
||||||
|
version = "0.1.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "indexmap"
|
||||||
|
version = "1.9.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"hashbrown",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itertools"
|
||||||
|
version = "0.10.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "1.0.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.66"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca"
|
||||||
|
dependencies = [
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lazy_static"
|
||||||
|
version = "1.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.150"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.6.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memoffset"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "minimal-lexical"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nom"
|
||||||
|
version = "7.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
"minimal-lexical",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.18.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "oorandom"
|
||||||
|
version = "11.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "os_str_bytes"
|
||||||
|
version = "6.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
"plotters-backend",
|
||||||
|
"plotters-svg",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters-backend"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters-svg"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab"
|
||||||
|
dependencies = [
|
||||||
|
"plotters-backend",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.70"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.33"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rayon"
|
||||||
|
version = "1.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
"rayon-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rayon-core"
|
||||||
|
version = "1.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-deque",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex"
|
||||||
|
version = "1.10.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-automata",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-automata"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-syntax"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "same-file"
|
||||||
|
version = "1.0.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scopeguard"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.193"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.193"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.108"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strum"
|
||||||
|
version = "0.25.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strum_macros"
|
||||||
|
version = "0.25.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0"
|
||||||
|
dependencies = [
|
||||||
|
"heck",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"rustversion",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.39"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "textwrap"
|
||||||
|
version = "0.16.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tinytemplate"
|
||||||
|
version = "1.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "walkdir"
|
||||||
|
version = "2.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
|
||||||
|
dependencies = [
|
||||||
|
"same-file",
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-backend"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"log",
|
||||||
|
"once_cell",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-backend",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "web-sys"
|
||||||
|
version = "0.3.66"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f"
|
||||||
|
dependencies = [
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-i686-pc-windows-gnu",
|
||||||
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-util"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
22
day_07/Cargo.toml
Normal file
22
day_07/Cargo.toml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
[package]
|
||||||
|
name = "day_07"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
nom = "7.1.3"
|
||||||
|
strum = "0.25.0"
|
||||||
|
strum_macros = "0.25.3"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
criterion = { version = "0.4", features = ["html_reports"] }
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "part1"
|
||||||
|
harness = false
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "part2"
|
||||||
|
harness = false
|
||||||
11
day_07/benches/part1.rs
Normal file
11
day_07/benches/part1.rs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
|
use day_07::prelude::*;
|
||||||
|
|
||||||
|
fn criterion_benchmark(c: &mut Criterion) {
|
||||||
|
let input = include_str!("../input.txt");
|
||||||
|
c.bench_function("part 1", |b| b.iter(|| part1(black_box(input))));
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
criterion_main!(benches);
|
||||||
11
day_07/benches/part2.rs
Normal file
11
day_07/benches/part2.rs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
|
use day_07::prelude::*;
|
||||||
|
|
||||||
|
fn criterion_benchmark(c: &mut Criterion) {
|
||||||
|
let input = include_str!("../input.txt");
|
||||||
|
c.bench_function("part 2", |b| b.iter(|| part2(black_box(input))));
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
criterion_main!(benches);
|
||||||
1000
day_07/input.txt
Normal file
1000
day_07/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
171
day_07/src/lib.rs
Normal file
171
day_07/src/lib.rs
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
use nom::{
|
||||||
|
bytes::complete::take,
|
||||||
|
character::complete::{
|
||||||
|
self, space1,
|
||||||
|
},
|
||||||
|
sequence::preceded,
|
||||||
|
IResult,
|
||||||
|
};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
// 393J3 50208020002 836
|
||||||
|
// 3TJAJ 50209001200 837
|
||||||
|
|
||||||
|
fn is_five_of_a_kind(card: &str, match_numbers: Vec<usize>) -> bool {
|
||||||
|
if match_numbers.iter().any(|x| {x==&5}) {
|
||||||
|
true
|
||||||
|
} else if match_numbers.iter().any(|x| {x==&4}) && card.matches("J").count() == 1 {
|
||||||
|
true
|
||||||
|
} else if match_numbers.iter().any(|x| {x==&3}) && card.matches("J").count() == 2 {
|
||||||
|
true
|
||||||
|
} else if match_numbers.iter().any(|x| {x==&2}) && card.matches("J").count() == 3 {
|
||||||
|
true
|
||||||
|
} else if match_numbers.iter().any(|x| {x==&1}) && card.matches("J").count() == 4 {
|
||||||
|
true
|
||||||
|
} else if card.matches("J").count() == 5 {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_four_of_a_kind(card: &str, match_numbers: Vec<usize>) -> bool {
|
||||||
|
if match_numbers.iter().any(|x| {x==&4}) {
|
||||||
|
true
|
||||||
|
} else if match_numbers.iter().any(|x| {x==&3}) && card.matches("J").count() == 1 {
|
||||||
|
true
|
||||||
|
} else if match_numbers.iter().any(|x| {x==&2}) && card.matches("J").count() == 2 {
|
||||||
|
true
|
||||||
|
} else if card.matches("J").count() == 3 {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_full_house(card: &str, match_numbers: Vec<usize>) -> bool {
|
||||||
|
if match_numbers.iter().filter(|x| x > &&0).count() == 2 && match_numbers.iter().sum::<usize>() == 5 {
|
||||||
|
true
|
||||||
|
} else if match_numbers.iter().filter(|x| x == &&2).count() == 2 && card.matches("J").count() == 1 {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_three_of_a_kind(card: &str, match_numbers: Vec<usize>) -> bool {
|
||||||
|
if match_numbers.iter().any(|x| {x==&3}) {
|
||||||
|
true
|
||||||
|
} else if match_numbers.iter().any(|x| {x==&2}) && card.matches("J").count() == 1 {
|
||||||
|
true
|
||||||
|
} else if card.matches("J").count() == 2 {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_two_pair(_card: &str, match_numbers: Vec<usize>) -> bool {
|
||||||
|
if match_numbers.iter().filter(|x| x == &&2).count() == 2 {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_pair(card: &str, match_numbers: Vec<usize>) -> bool {
|
||||||
|
if match_numbers.iter().any(|x| {x==&2}) {
|
||||||
|
true
|
||||||
|
} else if card.matches("J").count() == 1 {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn score_card_pt2(card: &str) -> u64 {
|
||||||
|
let values = HashMap::from(
|
||||||
|
[('2', 1),('3', 2),('4', 3),('5', 4),('6', 5),('7', 6),('8', 7),('9', 8),('T', 9),('J', 0),('Q', 10),('K', 11),('A', 12)]
|
||||||
|
);
|
||||||
|
let values_without_joker = HashMap::from(
|
||||||
|
[('2', 1),('3', 2),('4', 3),('5', 4),('6', 5),('7', 6),('8', 7),('9', 8),('T', 9),('Q', 10),('K', 11),('A', 12)]
|
||||||
|
);
|
||||||
|
let sub_score = card.chars().enumerate().fold(0, |acc, (i, character)| {
|
||||||
|
acc + values.get(&character).unwrap() * 10_u64.pow(8 - 2*i as u32)
|
||||||
|
});
|
||||||
|
let match_numbers = values_without_joker.keys().map(|value| { card.matches(*value).count() }).collect::<Vec<usize>>();
|
||||||
|
|
||||||
|
if is_five_of_a_kind(card, match_numbers.clone()) {
|
||||||
|
6 * 10_u64.pow(10) + sub_score
|
||||||
|
} else if is_four_of_a_kind(card, match_numbers.clone()) {
|
||||||
|
5 * 10_u64.pow(10) + sub_score
|
||||||
|
} else if is_full_house(card, match_numbers.clone()) {
|
||||||
|
4 * 10_u64.pow(10) + sub_score
|
||||||
|
} else if is_three_of_a_kind(card, match_numbers.clone()) {
|
||||||
|
3 * 10_u64.pow(10) + sub_score
|
||||||
|
} else if is_two_pair(card, match_numbers.clone()) {
|
||||||
|
2 * 10_u64.pow(10) + sub_score
|
||||||
|
} else if is_pair(card, match_numbers.clone()) {
|
||||||
|
1 * 10_u64.pow(10) + sub_score
|
||||||
|
} else {
|
||||||
|
sub_score
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn score_card(card: &str) -> u64 {
|
||||||
|
let values = HashMap::from(
|
||||||
|
[('2', 0),('3', 1),('4', 2),('5', 3),('6', 4),('7', 5),('8', 6),('9', 7),('T', 8),('J', 9),('Q', 10),('K', 11),('A', 12)]
|
||||||
|
);
|
||||||
|
let sub_score = card.chars().enumerate().fold(0, |acc, (i, character)| {
|
||||||
|
acc + values.get(&character).unwrap() * 10_u64.pow(8 - 2*i as u32)
|
||||||
|
});
|
||||||
|
let match_numbers = values.keys().map(|value| { card.matches(*value).count() });
|
||||||
|
if match_numbers.clone().any(|x| {x==5}) {
|
||||||
|
6 * 10_u64.pow(10) + sub_score
|
||||||
|
} else if match_numbers.clone().any(|x| {x==4}) {
|
||||||
|
5 * 10_u64.pow(10) + sub_score
|
||||||
|
} else if match_numbers.clone().filter(|x| x > &0).count() == 2 && match_numbers.clone().sum::<usize>() == 5 {
|
||||||
|
4 * 10_u64.pow(10) + sub_score
|
||||||
|
} else if match_numbers.clone().any(|x| {x==3}) {
|
||||||
|
3 * 10_u64.pow(10) + sub_score
|
||||||
|
} else if match_numbers.clone().filter(|x| x > &0).count() == 3 {
|
||||||
|
2 * 10_u64.pow(10) + sub_score
|
||||||
|
} else if match_numbers.clone().any(|x| {x==2}) {
|
||||||
|
1 * 10_u64.pow(10) + sub_score
|
||||||
|
} else {
|
||||||
|
sub_score
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_card(input: &str) -> IResult<&str, (&str, u64)> {
|
||||||
|
let (input, card) = take(5 as usize)(input)?;
|
||||||
|
let (input, bid) = preceded(space1, complete::u64)(input)?;
|
||||||
|
Ok((input, (card, bid)))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn part1(input: &str) -> String {
|
||||||
|
let mut scored_hands = input.lines().map(|line| {
|
||||||
|
let (_, (card, bid)) = parse_card(line).unwrap();
|
||||||
|
let score = score_card(card);
|
||||||
|
(card, score, bid)
|
||||||
|
}).collect::<Vec<_>>();
|
||||||
|
scored_hands.sort_by_key(|x| {x.1});
|
||||||
|
scored_hands.into_iter().enumerate().map(|(i, (_, _, bid))| { (i as u64 + 1) * bid }).sum::<u64>().to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn part2(input: &str) -> String {
|
||||||
|
let mut scored_hands = input.lines().map(|line| {
|
||||||
|
let (_, (card, bid)) = parse_card(line).unwrap();
|
||||||
|
let score = score_card_pt2(card);
|
||||||
|
(card, score, bid)
|
||||||
|
}).collect::<Vec<_>>();
|
||||||
|
scored_hands.sort_by_key(|x| {x.1});
|
||||||
|
scored_hands.iter().enumerate().for_each(|(i, (card, score, _))| {println!("{} {} {}", card, score, i);});
|
||||||
|
scored_hands.into_iter().enumerate().map(|(i, (_, _, bid))| { (i as u64 + 1) * bid }).sum::<u64>().to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod prelude {
|
||||||
|
pub use super::part1;
|
||||||
|
pub use super::part2;
|
||||||
|
}
|
||||||
|
|
||||||
33
day_07/src/main.rs
Normal file
33
day_07/src/main.rs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
use day_07::prelude::*;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let input = include_str!("../input.txt");
|
||||||
|
println!("{}", part1(input));
|
||||||
|
println!("{}", part2(input));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part1() {
|
||||||
|
let test_input = "32T3K 765
|
||||||
|
T55J5 684
|
||||||
|
KK677 28
|
||||||
|
KTJJT 220
|
||||||
|
QQQJA 483";
|
||||||
|
assert_eq!(part1(test_input), "6440".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part2() {
|
||||||
|
let test_input = "32T3K 765
|
||||||
|
T55J5 684
|
||||||
|
KK677 28
|
||||||
|
KTJJT 220
|
||||||
|
QQQJA 483";
|
||||||
|
assert_eq!(part2(test_input), "5905".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
639
day_08/Cargo.lock
generated
Normal file
639
day_08/Cargo.lock
generated
Normal file
@@ -0,0 +1,639 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aho-corasick"
|
||||||
|
version = "1.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "anes"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atty"
|
||||||
|
version = "0.2.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||||
|
dependencies = [
|
||||||
|
"hermit-abi",
|
||||||
|
"libc",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "1.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.14.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cast"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926"
|
||||||
|
dependencies = [
|
||||||
|
"ciborium-io",
|
||||||
|
"ciborium-ll",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium-io"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ciborium-ll"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b"
|
||||||
|
dependencies = [
|
||||||
|
"ciborium-io",
|
||||||
|
"half",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap"
|
||||||
|
version = "3.2.25"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"clap_lex",
|
||||||
|
"indexmap",
|
||||||
|
"textwrap",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_lex"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
|
||||||
|
dependencies = [
|
||||||
|
"os_str_bytes",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "criterion"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb"
|
||||||
|
dependencies = [
|
||||||
|
"anes",
|
||||||
|
"atty",
|
||||||
|
"cast",
|
||||||
|
"ciborium",
|
||||||
|
"clap",
|
||||||
|
"criterion-plot",
|
||||||
|
"itertools",
|
||||||
|
"lazy_static",
|
||||||
|
"num-traits",
|
||||||
|
"oorandom",
|
||||||
|
"plotters",
|
||||||
|
"rayon",
|
||||||
|
"regex",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
"serde_json",
|
||||||
|
"tinytemplate",
|
||||||
|
"walkdir",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "criterion-plot"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
|
||||||
|
dependencies = [
|
||||||
|
"cast",
|
||||||
|
"itertools",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-deque"
|
||||||
|
version = "0.8.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"crossbeam-epoch",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-epoch"
|
||||||
|
version = "0.9.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"cfg-if",
|
||||||
|
"crossbeam-utils",
|
||||||
|
"memoffset",
|
||||||
|
"scopeguard",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-utils"
|
||||||
|
version = "0.8.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "day_08"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"criterion",
|
||||||
|
"nom",
|
||||||
|
"strum",
|
||||||
|
"strum_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "either"
|
||||||
|
version = "1.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "half"
|
||||||
|
version = "1.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.12.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "heck"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hermit-abi"
|
||||||
|
version = "0.1.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "indexmap"
|
||||||
|
version = "1.9.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"hashbrown",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itertools"
|
||||||
|
version = "0.10.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "1.0.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.66"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca"
|
||||||
|
dependencies = [
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lazy_static"
|
||||||
|
version = "1.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.150"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.6.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memoffset"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "minimal-lexical"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nom"
|
||||||
|
version = "7.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
"minimal-lexical",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.18.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "oorandom"
|
||||||
|
version = "11.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "os_str_bytes"
|
||||||
|
version = "6.6.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
"plotters-backend",
|
||||||
|
"plotters-svg",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters-backend"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "plotters-svg"
|
||||||
|
version = "0.3.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab"
|
||||||
|
dependencies = [
|
||||||
|
"plotters-backend",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.70"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.33"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rayon"
|
||||||
|
version = "1.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
"rayon-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rayon-core"
|
||||||
|
version = "1.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-deque",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex"
|
||||||
|
version = "1.10.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-automata",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-automata"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-syntax"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustversion"
|
||||||
|
version = "1.0.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "same-file"
|
||||||
|
version = "1.0.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scopeguard"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.193"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.193"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.108"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strum"
|
||||||
|
version = "0.25.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strum_macros"
|
||||||
|
version = "0.25.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0"
|
||||||
|
dependencies = [
|
||||||
|
"heck",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"rustversion",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.39"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "textwrap"
|
||||||
|
version = "0.16.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tinytemplate"
|
||||||
|
version = "1.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "walkdir"
|
||||||
|
version = "2.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
|
||||||
|
dependencies = [
|
||||||
|
"same-file",
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"wasm-bindgen-macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-backend"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"log",
|
||||||
|
"once_cell",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"wasm-bindgen-backend",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "web-sys"
|
||||||
|
version = "0.3.66"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f"
|
||||||
|
dependencies = [
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-i686-pc-windows-gnu",
|
||||||
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-util"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
22
day_08/Cargo.toml
Normal file
22
day_08/Cargo.toml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
[package]
|
||||||
|
name = "day_08"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
nom = "7.1.3"
|
||||||
|
strum = "0.25.0"
|
||||||
|
strum_macros = "0.25.3"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
criterion = { version = "0.4", features = ["html_reports"] }
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "part1"
|
||||||
|
harness = false
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "part2"
|
||||||
|
harness = false
|
||||||
11
day_08/benches/part1.rs
Normal file
11
day_08/benches/part1.rs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
|
use day_08::prelude::*;
|
||||||
|
|
||||||
|
fn criterion_benchmark(c: &mut Criterion) {
|
||||||
|
let input = include_str!("../input.txt");
|
||||||
|
c.bench_function("part 1", |b| b.iter(|| part1(black_box(input))));
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
criterion_main!(benches);
|
||||||
11
day_08/benches/part2.rs
Normal file
11
day_08/benches/part2.rs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
|
use day_08::prelude::*;
|
||||||
|
|
||||||
|
fn criterion_benchmark(c: &mut Criterion) {
|
||||||
|
let input = include_str!("../input.txt");
|
||||||
|
c.bench_function("part 2", |b| b.iter(|| part2(black_box(input))));
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
criterion_main!(benches);
|
||||||
752
day_08/input.txt
Normal file
752
day_08/input.txt
Normal file
@@ -0,0 +1,752 @@
|
|||||||
|
LRRLLRLRRRLRRRLRRLRRRLRRLRRRLRRLRRRLRLRRRLRRRLRRRLRLRRLRRRLRRRLRRLRRLRRLRLLLRRRLRRRLRLRLRRLLRRRLRRLRRRLRLRRLRRRLRRRLLRLRLLRRRLRRRLLRRRLRRRLRRRLRRLRRRLLLRRRLRLLLRLRLRLLRLRLLLRRLRRLLRRLRRRLRRLRRLRLRRLLRRLRLRRLLLRRRLLRRRLLRLRLLRRRLRLLRRLRLRRLRLRRRLLRRRLLRRLRLRRLRRLLRLRLRRRLRLRRRR
|
||||||
|
|
||||||
|
GLJ = (QQV, JTL)
|
||||||
|
JSJ = (DKN, GQN)
|
||||||
|
MGD = (BPL, LQC)
|
||||||
|
VSK = (SPH, DDH)
|
||||||
|
TSB = (MKP, TKX)
|
||||||
|
HPD = (GKG, XMX)
|
||||||
|
BLZ = (HGN, KRR)
|
||||||
|
BMQ = (JXC, HFC)
|
||||||
|
GDG = (BVJ, NBL)
|
||||||
|
LST = (PVJ, DPR)
|
||||||
|
QQQ = (RLV, SNJ)
|
||||||
|
TMV = (XGV, KCL)
|
||||||
|
NPZ = (JRD, NHL)
|
||||||
|
DDH = (NDR, XPN)
|
||||||
|
SFQ = (TKD, SQH)
|
||||||
|
RNK = (TJN, NFX)
|
||||||
|
FRS = (SCJ, FDV)
|
||||||
|
RST = (BSQ, MHQ)
|
||||||
|
DSM = (FRX, DMN)
|
||||||
|
GBN = (VBL, XRK)
|
||||||
|
GLH = (KNN, PKP)
|
||||||
|
JRD = (LDP, RNH)
|
||||||
|
SPV = (JNR, FRK)
|
||||||
|
PMD = (FXP, BKL)
|
||||||
|
MDV = (MGD, FHM)
|
||||||
|
MGG = (KMN, QPL)
|
||||||
|
FNX = (FKG, NLT)
|
||||||
|
FPH = (QXS, PBR)
|
||||||
|
DKP = (QFT, QQQ)
|
||||||
|
XVH = (PVP, GBJ)
|
||||||
|
SSP = (BHD, KRM)
|
||||||
|
JVR = (RHB, LDJ)
|
||||||
|
HCX = (RNK, LGT)
|
||||||
|
LRX = (SFN, GXD)
|
||||||
|
DXN = (NQX, KNL)
|
||||||
|
GNT = (GHV, DKG)
|
||||||
|
QVF = (NJN, FSN)
|
||||||
|
QHQ = (FXN, PNP)
|
||||||
|
CHX = (DHN, BQB)
|
||||||
|
GQD = (TLQ, XXG)
|
||||||
|
RMF = (RVF, KKR)
|
||||||
|
JHN = (NRG, RCC)
|
||||||
|
MBG = (XPV, MSB)
|
||||||
|
XJN = (SQT, XXJ)
|
||||||
|
JNR = (VTP, XSF)
|
||||||
|
NXD = (DKP, MKJ)
|
||||||
|
LSS = (KHS, BSV)
|
||||||
|
SQH = (BLH, VCG)
|
||||||
|
TLM = (DCG, BQL)
|
||||||
|
HTG = (TLF, KRB)
|
||||||
|
GGM = (KLV, PTG)
|
||||||
|
PVJ = (BHR, TRH)
|
||||||
|
PRP = (QLC, JPQ)
|
||||||
|
CVC = (KVJ, FTM)
|
||||||
|
RMH = (RPD, FFK)
|
||||||
|
MRL = (KFK, LJK)
|
||||||
|
VMG = (LSX, FPH)
|
||||||
|
DKQ = (XSM, CXK)
|
||||||
|
QBD = (BGB, GPS)
|
||||||
|
RFV = (QCG, NJD)
|
||||||
|
FDN = (QFL, DXN)
|
||||||
|
RMV = (NCJ, PMZ)
|
||||||
|
BCJ = (MDD, TMG)
|
||||||
|
BMB = (GLH, MKK)
|
||||||
|
DLQ = (JKX, VGS)
|
||||||
|
NBL = (GFQ, PRQ)
|
||||||
|
NVG = (SCS, JTS)
|
||||||
|
CBX = (MXQ, QSM)
|
||||||
|
HFJ = (NXX, VRX)
|
||||||
|
FMQ = (KDV, HFJ)
|
||||||
|
DSK = (BND, GFJ)
|
||||||
|
TRM = (MMX, BTG)
|
||||||
|
XKS = (GXD, SFN)
|
||||||
|
LDJ = (TFQ, CJK)
|
||||||
|
LFP = (TFS, LST)
|
||||||
|
PQS = (PJR, SMD)
|
||||||
|
MTA = (JPD, MVX)
|
||||||
|
FMM = (GPC, BVB)
|
||||||
|
NJD = (JMG, DPL)
|
||||||
|
VQJ = (KRM, BHD)
|
||||||
|
PXP = (BPB, JJK)
|
||||||
|
JDM = (HHQ, JXD)
|
||||||
|
BJK = (SRN, DRL)
|
||||||
|
MRS = (RPT, SQF)
|
||||||
|
RCC = (DRD, SPP)
|
||||||
|
XPG = (XRK, VBL)
|
||||||
|
JLR = (LJQ, XDP)
|
||||||
|
KLV = (SKX, SKX)
|
||||||
|
JBB = (LRB, RRT)
|
||||||
|
NDP = (KMS, DDJ)
|
||||||
|
XML = (TPD, VKQ)
|
||||||
|
TPM = (PKJ, PGR)
|
||||||
|
DGQ = (JFK, TMB)
|
||||||
|
XTL = (MPK, CTL)
|
||||||
|
VSH = (BNH, HJR)
|
||||||
|
PVG = (SPV, KCS)
|
||||||
|
CCQ = (LQB, VTK)
|
||||||
|
PLS = (HPS, CVC)
|
||||||
|
GMQ = (CTG, QHQ)
|
||||||
|
PNP = (VSK, JCV)
|
||||||
|
JPD = (KKV, FQP)
|
||||||
|
PRL = (KRB, TLF)
|
||||||
|
NMT = (HXL, NHV)
|
||||||
|
DLP = (KXR, BXQ)
|
||||||
|
NFG = (DSR, HNX)
|
||||||
|
BPB = (BTM, MGR)
|
||||||
|
JPL = (NMT, QMD)
|
||||||
|
HJG = (XJD, HHX)
|
||||||
|
BBK = (VVF, SBN)
|
||||||
|
GQL = (XNX, CKR)
|
||||||
|
BND = (SQB, KFG)
|
||||||
|
VRF = (JKS, LGG)
|
||||||
|
PXG = (QMD, NMT)
|
||||||
|
FKG = (GBS, JLR)
|
||||||
|
NCJ = (NFG, CQH)
|
||||||
|
CVM = (LFD, NPZ)
|
||||||
|
GQN = (SMM, PQH)
|
||||||
|
LJQ = (LXQ, KVG)
|
||||||
|
PFK = (HHQ, JXD)
|
||||||
|
KLQ = (JNB, DKQ)
|
||||||
|
QRP = (SCB, HCM)
|
||||||
|
LRB = (RMD, KLN)
|
||||||
|
XPP = (GMK, LKL)
|
||||||
|
LFD = (NHL, JRD)
|
||||||
|
TVK = (TMV, TJF)
|
||||||
|
MQD = (HTG, PRL)
|
||||||
|
MKJ = (QQQ, QFT)
|
||||||
|
QLF = (CHX, XSR)
|
||||||
|
MPP = (XMK, QFP)
|
||||||
|
HQQ = (PCS, PDC)
|
||||||
|
NXX = (BTN, KBJ)
|
||||||
|
JBQ = (GGH, FJL)
|
||||||
|
BGB = (JSF, MNP)
|
||||||
|
BRD = (VMF, NTR)
|
||||||
|
HCM = (RHX, KJG)
|
||||||
|
NKP = (GHV, DKG)
|
||||||
|
XJK = (TRS, DGQ)
|
||||||
|
GPS = (MNP, JSF)
|
||||||
|
NCM = (VMJ, CSC)
|
||||||
|
LSX = (PBR, QXS)
|
||||||
|
VLF = (MTL, GVK)
|
||||||
|
XFT = (XGS, CRL)
|
||||||
|
HLR = (FMM, QLH)
|
||||||
|
FFR = (XXX, BGX)
|
||||||
|
MRB = (XJD, HHX)
|
||||||
|
TVS = (MTL, GVK)
|
||||||
|
KNL = (KDN, HQQ)
|
||||||
|
PNV = (SQF, RPT)
|
||||||
|
HVB = (BBB, LLG)
|
||||||
|
RGX = (RLK, MSX)
|
||||||
|
MKB = (HNP, NGM)
|
||||||
|
FKL = (XMK, QFP)
|
||||||
|
LXQ = (GNB, TQH)
|
||||||
|
CQF = (NGF, NQF)
|
||||||
|
BSV = (KFX, HNH)
|
||||||
|
SVQ = (PXP, XQM)
|
||||||
|
BHD = (XVH, GDN)
|
||||||
|
QQB = (PCB, PCB)
|
||||||
|
DCG = (GRH, RGX)
|
||||||
|
RRT = (KLN, RMD)
|
||||||
|
KDN = (PDC, PCS)
|
||||||
|
RHJ = (VTK, LQB)
|
||||||
|
LVR = (VSH, QGS)
|
||||||
|
NHT = (LQS, DMB)
|
||||||
|
PBR = (TCF, JCC)
|
||||||
|
GBJ = (MLT, XNB)
|
||||||
|
BJB = (XPR, MBG)
|
||||||
|
PQH = (MCH, LMB)
|
||||||
|
MPM = (BSV, KHS)
|
||||||
|
SGB = (TKF, PMD)
|
||||||
|
XQM = (JJK, BPB)
|
||||||
|
TLQ = (FGM, CRC)
|
||||||
|
FXP = (BCJ, TDR)
|
||||||
|
VDG = (VMJ, CSC)
|
||||||
|
XGV = (LHS, LTS)
|
||||||
|
JKP = (PXG, JPL)
|
||||||
|
KFQ = (TSB, RNB)
|
||||||
|
NHL = (LDP, RNH)
|
||||||
|
TRS = (JFK, TMB)
|
||||||
|
PMM = (RHC, KMQ)
|
||||||
|
QMB = (PPJ, CNG)
|
||||||
|
MKH = (DDJ, KMS)
|
||||||
|
NCG = (XXX, BGX)
|
||||||
|
DBG = (SND, HMN)
|
||||||
|
GVK = (TQD, JHN)
|
||||||
|
KKM = (KKL, PBT)
|
||||||
|
HLP = (JPQ, QLC)
|
||||||
|
GPH = (JKG, DKK)
|
||||||
|
XQP = (GLH, MKK)
|
||||||
|
HRF = (BGB, GPS)
|
||||||
|
BXQ = (BDH, GQT)
|
||||||
|
NDR = (KKM, LRR)
|
||||||
|
HQR = (RGL, RMX)
|
||||||
|
PCS = (DTB, LDS)
|
||||||
|
LQB = (GMQ, HRQ)
|
||||||
|
KKR = (KTV, CMB)
|
||||||
|
NGM = (KFQ, BQJ)
|
||||||
|
KLN = (XFT, JRL)
|
||||||
|
HRR = (RHJ, CCQ)
|
||||||
|
XSF = (CKX, PLS)
|
||||||
|
BTG = (GDG, JDS)
|
||||||
|
PBT = (NVG, DVP)
|
||||||
|
CPP = (VSH, QGS)
|
||||||
|
MLN = (VGS, JKX)
|
||||||
|
JRF = (SKN, RMF)
|
||||||
|
KHS = (KFX, HNH)
|
||||||
|
DDP = (QJG, XKJ)
|
||||||
|
FGM = (TVK, TNS)
|
||||||
|
QJH = (XSL, QXP)
|
||||||
|
TNX = (NBV, KLQ)
|
||||||
|
JVC = (FBR, PFT)
|
||||||
|
XPV = (TLM, PPK)
|
||||||
|
PCK = (KBG, TGJ)
|
||||||
|
HRS = (VKM, JVF)
|
||||||
|
DKK = (NHT, ZZZ)
|
||||||
|
TJN = (KTL, QLF)
|
||||||
|
THT = (JJQ, LRJ)
|
||||||
|
JNB = (CXK, XSM)
|
||||||
|
CRL = (VXT, TBG)
|
||||||
|
RVF = (CMB, KTV)
|
||||||
|
GQT = (PBB, CVM)
|
||||||
|
QGF = (MGT, SKV)
|
||||||
|
SCJ = (CQF, KRQ)
|
||||||
|
SCM = (DPB, PMM)
|
||||||
|
KNN = (XLQ, VPB)
|
||||||
|
PPK = (BQL, DCG)
|
||||||
|
LPP = (HJG, MRB)
|
||||||
|
RRM = (RXT, PBZ)
|
||||||
|
DCT = (FTF, HVB)
|
||||||
|
PQP = (PBQ, HVR)
|
||||||
|
NTV = (SCM, GKN)
|
||||||
|
XXX = (LSS, MPM)
|
||||||
|
BKP = (LXL, LXL)
|
||||||
|
BLH = (QLV, SFJ)
|
||||||
|
SPH = (NDR, XPN)
|
||||||
|
CVF = (KDV, HFJ)
|
||||||
|
XDK = (RHJ, CCQ)
|
||||||
|
NQQ = (NTT, FVL)
|
||||||
|
TQF = (XCV, NDX)
|
||||||
|
VRX = (BTN, KBJ)
|
||||||
|
KFX = (XLN, FDN)
|
||||||
|
DMN = (TPT, JRQ)
|
||||||
|
VVF = (TPQ, CDH)
|
||||||
|
XPN = (LRR, KKM)
|
||||||
|
LQC = (TMX, LHQ)
|
||||||
|
XXT = (TLR, DDP)
|
||||||
|
PBB = (LFD, LFD)
|
||||||
|
GKF = (CHM, XTL)
|
||||||
|
SNJ = (NSR, KVD)
|
||||||
|
FKS = (PPL, PSM)
|
||||||
|
BJZ = (MVX, JPD)
|
||||||
|
JSF = (GQD, GQP)
|
||||||
|
BFM = (QXR, MVF)
|
||||||
|
QSD = (JHV, JKP)
|
||||||
|
XSR = (DHN, BQB)
|
||||||
|
SVM = (PKJ, PGR)
|
||||||
|
XXJ = (HGF, MPG)
|
||||||
|
KRB = (QMB, VNX)
|
||||||
|
XJD = (SFQ, SGF)
|
||||||
|
HGN = (KBF, LXS)
|
||||||
|
TKF = (FXP, BKL)
|
||||||
|
KHB = (TPJ, CGD)
|
||||||
|
JFK = (JJX, DMH)
|
||||||
|
PMT = (HGC, HJQ)
|
||||||
|
NBV = (DKQ, JNB)
|
||||||
|
FMN = (BJB, HSV)
|
||||||
|
HPS = (KVJ, KVJ)
|
||||||
|
GLT = (LXL, NFN)
|
||||||
|
PSM = (PMT, CKP)
|
||||||
|
RSM = (JRF, PDB)
|
||||||
|
KVD = (PFK, JDM)
|
||||||
|
CSQ = (HJG, MRB)
|
||||||
|
PKJ = (HDR, TJQ)
|
||||||
|
LRJ = (JSJ, BFS)
|
||||||
|
KFG = (KKT, CQR)
|
||||||
|
TPD = (THT, KBB)
|
||||||
|
KBB = (LRJ, JJQ)
|
||||||
|
XGS = (VXT, TBG)
|
||||||
|
RHX = (XJK, QND)
|
||||||
|
QPL = (DDN, STH)
|
||||||
|
BQB = (XJC, SBH)
|
||||||
|
KCL = (LHS, LTS)
|
||||||
|
XPH = (KXR, BXQ)
|
||||||
|
QNA = (NHL, JRD)
|
||||||
|
KVJ = (KHJ, KHJ)
|
||||||
|
QJP = (RNK, LGT)
|
||||||
|
QFL = (KNL, NQX)
|
||||||
|
KFP = (HLR, LCV)
|
||||||
|
QLV = (PMX, BJK)
|
||||||
|
TLR = (QJG, XKJ)
|
||||||
|
NLQ = (XML, BDS)
|
||||||
|
JXD = (MQD, GBH)
|
||||||
|
LXP = (HRR, XDK)
|
||||||
|
DJS = (GLJ, RNF)
|
||||||
|
FLS = (FMB, MRL)
|
||||||
|
HXL = (BXS, FDM)
|
||||||
|
NQX = (KDN, HQQ)
|
||||||
|
PGR = (TJQ, HDR)
|
||||||
|
CGD = (DGS, VKN)
|
||||||
|
KRQ = (NQF, NGF)
|
||||||
|
JSB = (PNQ, DHV)
|
||||||
|
MBJ = (JCK, QRP)
|
||||||
|
MXQ = (DRG, DSM)
|
||||||
|
HMN = (CBP, CPG)
|
||||||
|
JTL = (RST, SPD)
|
||||||
|
DKG = (GQK, XMQ)
|
||||||
|
NJN = (TVS, VLF)
|
||||||
|
LTS = (JCB, TQF)
|
||||||
|
XNP = (JVF, VKM)
|
||||||
|
RTG = (XXJ, SQT)
|
||||||
|
KNT = (LRB, RRT)
|
||||||
|
SFL = (LXP, CDN)
|
||||||
|
GXD = (MMT, CNX)
|
||||||
|
SMC = (XTL, CHM)
|
||||||
|
JCB = (XCV, NDX)
|
||||||
|
DQT = (RBJ, QGF)
|
||||||
|
TFR = (MKH, NDP)
|
||||||
|
HTP = (CSQ, LPP)
|
||||||
|
JKM = (VVK, SHX)
|
||||||
|
LGG = (RPH, NTV)
|
||||||
|
NSR = (JDM, PFK)
|
||||||
|
QFT = (SNJ, RLV)
|
||||||
|
SQF = (GRG, RSX)
|
||||||
|
SFD = (FFK, RPD)
|
||||||
|
SCD = (SNC, LGQ)
|
||||||
|
CXK = (VDN, SQM)
|
||||||
|
LDP = (NLQ, DGV)
|
||||||
|
CDN = (XDK, HRR)
|
||||||
|
HFC = (QBD, HRF)
|
||||||
|
LGT = (NFX, TJN)
|
||||||
|
VKM = (QJP, HCX)
|
||||||
|
HGF = (SCD, TKT)
|
||||||
|
VGS = (SGB, VXD)
|
||||||
|
MGL = (FTN, LBF)
|
||||||
|
FDM = (DLQ, MLN)
|
||||||
|
FTP = (HJL, JQG)
|
||||||
|
TCN = (MRL, FMB)
|
||||||
|
NGR = (QPL, KMN)
|
||||||
|
NDX = (DMX, LTG)
|
||||||
|
GVJ = (JDG, PCK)
|
||||||
|
MVF = (KVR, TQK)
|
||||||
|
MXJ = (FPQ, VBV)
|
||||||
|
RNH = (DGV, NLQ)
|
||||||
|
RPD = (RFV, PGG)
|
||||||
|
JKG = (NHT, NHT)
|
||||||
|
XNX = (JDB, DQT)
|
||||||
|
DRL = (GCM, DSK)
|
||||||
|
TCF = (TCJ, SVQ)
|
||||||
|
LCL = (NJN, FSN)
|
||||||
|
MJM = (QSM, MXQ)
|
||||||
|
JJK = (BTM, MGR)
|
||||||
|
SPX = (JDG, PCK)
|
||||||
|
QLC = (DHJ, PVG)
|
||||||
|
GPC = (XKC, RTT)
|
||||||
|
TJQ = (XPG, GBN)
|
||||||
|
HSV = (XPR, MBG)
|
||||||
|
JKS = (RPH, NTV)
|
||||||
|
XDP = (KVG, LXQ)
|
||||||
|
JDS = (NBL, BVJ)
|
||||||
|
TQK = (NCR, HTP)
|
||||||
|
BLX = (TFS, LST)
|
||||||
|
KRR = (LXS, KBF)
|
||||||
|
XMQ = (KHB, MMC)
|
||||||
|
KBG = (DBG, MQR)
|
||||||
|
LRR = (KKL, PBT)
|
||||||
|
LFV = (HVQ, MNJ)
|
||||||
|
HGD = (MNL, PDJ)
|
||||||
|
GLB = (NDP, MKH)
|
||||||
|
CMB = (VDG, NCM)
|
||||||
|
TKD = (VCG, BLH)
|
||||||
|
BQJ = (TSB, RNB)
|
||||||
|
QBT = (MKB, RKM)
|
||||||
|
GJQ = (BTG, MMX)
|
||||||
|
SGF = (TKD, SQH)
|
||||||
|
RMD = (JRL, XFT)
|
||||||
|
DDJ = (HRS, XNP)
|
||||||
|
HNP = (KFQ, BQJ)
|
||||||
|
FQF = (MNJ, HVQ)
|
||||||
|
PJT = (FRQ, KFP)
|
||||||
|
RKM = (NGM, HNP)
|
||||||
|
VBV = (LVR, CPP)
|
||||||
|
RBJ = (SKV, MGT)
|
||||||
|
MPG = (SCD, TKT)
|
||||||
|
BHR = (BRM, FJC)
|
||||||
|
VTP = (CKX, PLS)
|
||||||
|
PBQ = (RQC, HGD)
|
||||||
|
RMX = (FTP, NGJ)
|
||||||
|
SMP = (KRR, HGN)
|
||||||
|
KBF = (RMK, BMQ)
|
||||||
|
LSL = (JSB, VPL)
|
||||||
|
KRM = (GDN, XVH)
|
||||||
|
DHJ = (SPV, KCS)
|
||||||
|
XNB = (QFH, PGQ)
|
||||||
|
TGJ = (DBG, MQR)
|
||||||
|
LHQ = (FNX, KFF)
|
||||||
|
GCM = (GFJ, BND)
|
||||||
|
MJQ = (BBK, KVM)
|
||||||
|
NQF = (SSP, VQJ)
|
||||||
|
VPL = (DHV, PNQ)
|
||||||
|
HHX = (SFQ, SGF)
|
||||||
|
FJL = (MGL, XKH)
|
||||||
|
HNH = (FDN, XLN)
|
||||||
|
RLK = (LCL, QVF)
|
||||||
|
SND = (CPG, CBP)
|
||||||
|
CNG = (DJS, HVS)
|
||||||
|
VDN = (QBK, MXJ)
|
||||||
|
BRM = (SMC, GKF)
|
||||||
|
VTK = (HRQ, GMQ)
|
||||||
|
MVX = (KKV, FQP)
|
||||||
|
TDR = (TMG, MDD)
|
||||||
|
SQT = (HGF, MPG)
|
||||||
|
TMN = (HVB, FTF)
|
||||||
|
GNB = (BFT, QXK)
|
||||||
|
QXP = (MJM, CBX)
|
||||||
|
GQK = (MMC, KHB)
|
||||||
|
QGX = (NDB, QSD)
|
||||||
|
TMX = (FNX, KFF)
|
||||||
|
BLD = (NBV, KLQ)
|
||||||
|
RHC = (NXK, PJT)
|
||||||
|
XJC = (QKG, QKG)
|
||||||
|
GBH = (HTG, PRL)
|
||||||
|
TPT = (TRQ, XXT)
|
||||||
|
FTF = (BBB, LLG)
|
||||||
|
QJG = (FKS, PQG)
|
||||||
|
FVR = (LXP, CDN)
|
||||||
|
XCA = (FVR, SFL)
|
||||||
|
VMJ = (KHP, MDV)
|
||||||
|
NTT = (LFP, BLX)
|
||||||
|
DMB = (TCN, FLS)
|
||||||
|
CQR = (LRX, XKS)
|
||||||
|
JFR = (TMN, DCT)
|
||||||
|
TRQ = (DDP, TLR)
|
||||||
|
BXS = (MLN, DLQ)
|
||||||
|
LLG = (LSK, XMD)
|
||||||
|
CBP = (RHF, BRD)
|
||||||
|
PFT = (SMP, BLZ)
|
||||||
|
TNS = (TMV, TJF)
|
||||||
|
DHV = (VFX, VVR)
|
||||||
|
PPL = (CKP, PMT)
|
||||||
|
QND = (DGQ, TRS)
|
||||||
|
VBL = (MGG, NGR)
|
||||||
|
FHM = (BPL, LQC)
|
||||||
|
KKT = (LRX, XKS)
|
||||||
|
LHS = (JCB, TQF)
|
||||||
|
LXL = (LJH, LJH)
|
||||||
|
BLT = (GGH, FJL)
|
||||||
|
JQG = (XCT, FRS)
|
||||||
|
KCS = (JNR, FRK)
|
||||||
|
SKX = (JKG, JKG)
|
||||||
|
VKN = (NMS, QBT)
|
||||||
|
DSL = (FMN, PJN)
|
||||||
|
TPJ = (VKN, DGS)
|
||||||
|
CKR = (JDB, DQT)
|
||||||
|
LKL = (QLQ, NXD)
|
||||||
|
SMM = (LMB, MCH)
|
||||||
|
FSN = (TVS, VLF)
|
||||||
|
KMS = (XNP, HRS)
|
||||||
|
MTX = (LGG, JKS)
|
||||||
|
CHM = (CTL, MPK)
|
||||||
|
HRQ = (QHQ, CTG)
|
||||||
|
QCG = (JMG, DPL)
|
||||||
|
TQH = (QXK, BFT)
|
||||||
|
JXC = (QBD, HRF)
|
||||||
|
JVF = (QJP, HCX)
|
||||||
|
TJF = (KCL, XGV)
|
||||||
|
XDS = (QQB, QQB)
|
||||||
|
KJG = (QND, XJK)
|
||||||
|
CTG = (FXN, PNP)
|
||||||
|
BBB = (LSK, XMD)
|
||||||
|
DMH = (NHF, JKM)
|
||||||
|
BGX = (LSS, MPM)
|
||||||
|
RHF = (VMF, NTR)
|
||||||
|
KHJ = (JPD, MVX)
|
||||||
|
SCS = (FNJ, RSM)
|
||||||
|
VFX = (LXV, XPP)
|
||||||
|
XLQ = (RMH, SFD)
|
||||||
|
HDB = (HVR, PBQ)
|
||||||
|
PTG = (SKX, GPH)
|
||||||
|
NTR = (LDG, LKV)
|
||||||
|
KKL = (NVG, DVP)
|
||||||
|
XKH = (FTN, LBF)
|
||||||
|
BDS = (TPD, VKQ)
|
||||||
|
QKG = (FBR, FBR)
|
||||||
|
LDS = (HQR, BJC)
|
||||||
|
KKV = (MPP, FKL)
|
||||||
|
JRQ = (TRQ, XXT)
|
||||||
|
MNP = (GQP, GQD)
|
||||||
|
BTM = (GJQ, TRM)
|
||||||
|
RPH = (GKN, SCM)
|
||||||
|
TQD = (RCC, NRG)
|
||||||
|
FQP = (FKL, MPP)
|
||||||
|
VFV = (QQB, HPB)
|
||||||
|
XSL = (CBX, MJM)
|
||||||
|
GKN = (DPB, PMM)
|
||||||
|
PBK = (QBH, GQL)
|
||||||
|
HPB = (PCB, RRM)
|
||||||
|
MCH = (RTG, XJN)
|
||||||
|
KSL = (FVL, NTT)
|
||||||
|
TCJ = (PXP, XQM)
|
||||||
|
RNF = (JTL, QQV)
|
||||||
|
BXA = (NFG, CQH)
|
||||||
|
KVK = (PRP, HLP)
|
||||||
|
NGF = (SSP, VQJ)
|
||||||
|
PJN = (BJB, HSV)
|
||||||
|
SFJ = (BJK, PMX)
|
||||||
|
CPL = (LDJ, RHB)
|
||||||
|
MKP = (TRJ, BFM)
|
||||||
|
RPT = (GRG, RSX)
|
||||||
|
PRQ = (XPH, DLP)
|
||||||
|
DSR = (KNT, JBB)
|
||||||
|
VPB = (RMH, SFD)
|
||||||
|
QLQ = (MKJ, DKP)
|
||||||
|
FNJ = (PDB, JRF)
|
||||||
|
SBH = (QKG, JVC)
|
||||||
|
PDC = (LDS, DTB)
|
||||||
|
QFP = (MJQ, HFK)
|
||||||
|
CTL = (RDD, KVK)
|
||||||
|
LXS = (BMQ, RMK)
|
||||||
|
VKF = (QBH, GQL)
|
||||||
|
HJL = (XCT, FRS)
|
||||||
|
KTK = (LDF, HPD)
|
||||||
|
RMK = (HFC, JXC)
|
||||||
|
MGT = (JFR, HXB)
|
||||||
|
XLN = (QFL, DXN)
|
||||||
|
FRQ = (HLR, LCV)
|
||||||
|
FMB = (KFK, LJK)
|
||||||
|
NFX = (KTL, QLF)
|
||||||
|
LMB = (RTG, XJN)
|
||||||
|
JDG = (TGJ, KBG)
|
||||||
|
MNJ = (GVJ, SPX)
|
||||||
|
VMF = (LDG, LKV)
|
||||||
|
SRN = (GCM, DSK)
|
||||||
|
JCC = (SVQ, TCJ)
|
||||||
|
NGJ = (HJL, JQG)
|
||||||
|
XCT = (SCJ, FDV)
|
||||||
|
FFK = (RFV, PGG)
|
||||||
|
NFN = (LJH, RMV)
|
||||||
|
GHV = (GQK, XMQ)
|
||||||
|
HFK = (KVM, BBK)
|
||||||
|
MNL = (GLB, TFR)
|
||||||
|
BPL = (LHQ, TMX)
|
||||||
|
LJH = (NCJ, NCJ)
|
||||||
|
FDV = (CQF, KRQ)
|
||||||
|
PBZ = (SFL, FVR)
|
||||||
|
MSB = (PPK, TLM)
|
||||||
|
GGH = (XKH, MGL)
|
||||||
|
MPK = (KVK, RDD)
|
||||||
|
VVR = (XPP, LXV)
|
||||||
|
NMS = (MKB, RKM)
|
||||||
|
NXK = (FRQ, KFP)
|
||||||
|
BSQ = (JCS, MBJ)
|
||||||
|
XMX = (DSL, CTX)
|
||||||
|
NHF = (VVK, SHX)
|
||||||
|
MMC = (CGD, TPJ)
|
||||||
|
GQP = (TLQ, XXG)
|
||||||
|
TRH = (FJC, BRM)
|
||||||
|
RLV = (NSR, KVD)
|
||||||
|
DKN = (PQH, SMM)
|
||||||
|
MSX = (LCL, QVF)
|
||||||
|
SKN = (KKR, RVF)
|
||||||
|
LSK = (PNV, MRS)
|
||||||
|
RDD = (PRP, HLP)
|
||||||
|
DRD = (JBQ, BLT)
|
||||||
|
GBS = (XDP, LJQ)
|
||||||
|
TFQ = (BLD, TNX)
|
||||||
|
QGS = (BNH, HJR)
|
||||||
|
LJK = (CVF, FMQ)
|
||||||
|
NCR = (CSQ, LPP)
|
||||||
|
HJQ = (SVM, TPM)
|
||||||
|
JCS = (QRP, JCK)
|
||||||
|
KTV = (VDG, NCM)
|
||||||
|
MMX = (GDG, JDS)
|
||||||
|
HVS = (GLJ, RNF)
|
||||||
|
XMD = (PNV, MRS)
|
||||||
|
VVK = (XDS, VFV)
|
||||||
|
FBR = (SMP, SMP)
|
||||||
|
XKJ = (PQG, FKS)
|
||||||
|
AAA = (LQS, DMB)
|
||||||
|
LCV = (FMM, QLH)
|
||||||
|
PPJ = (HVS, DJS)
|
||||||
|
DGS = (QBT, NMS)
|
||||||
|
PFG = (LDF, HPD)
|
||||||
|
HVR = (RQC, HGD)
|
||||||
|
QXK = (BMB, XQP)
|
||||||
|
BTN = (GHD, JXP)
|
||||||
|
DPR = (TRH, BHR)
|
||||||
|
KVG = (GNB, TQH)
|
||||||
|
GFJ = (KFG, SQB)
|
||||||
|
JCK = (SCB, HCM)
|
||||||
|
QSM = (DRG, DSM)
|
||||||
|
XPR = (XPV, MSB)
|
||||||
|
RNB = (TKX, MKP)
|
||||||
|
RHB = (TFQ, CJK)
|
||||||
|
PGQ = (VRF, MTX)
|
||||||
|
CDH = (GNT, NKP)
|
||||||
|
BVJ = (PRQ, GFQ)
|
||||||
|
LTG = (QGX, LVL)
|
||||||
|
XJR = (QXP, XSL)
|
||||||
|
JCV = (SPH, DDH)
|
||||||
|
GDN = (PVP, GBJ)
|
||||||
|
HNX = (KNT, JBB)
|
||||||
|
SFN = (MMT, CNX)
|
||||||
|
RGL = (FTP, NGJ)
|
||||||
|
VCA = (KRR, HGN)
|
||||||
|
ZZZ = (DMB, LQS)
|
||||||
|
GMK = (QLQ, NXD)
|
||||||
|
LKV = (VMG, SDQ)
|
||||||
|
PMZ = (CQH, NFG)
|
||||||
|
KBJ = (GHD, JXP)
|
||||||
|
PNQ = (VFX, VVR)
|
||||||
|
TPQ = (GNT, NKP)
|
||||||
|
SPD = (MHQ, BSQ)
|
||||||
|
XCV = (DMX, LTG)
|
||||||
|
BVB = (XKC, RTT)
|
||||||
|
BQL = (RGX, GRH)
|
||||||
|
JTS = (RSM, FNJ)
|
||||||
|
SPP = (BLT, JBQ)
|
||||||
|
VXT = (CPL, JVR)
|
||||||
|
MTL = (JHN, TQD)
|
||||||
|
KMN = (DDN, STH)
|
||||||
|
RQC = (PDJ, MNL)
|
||||||
|
FTM = (KHJ, BJZ)
|
||||||
|
RXT = (FVR, SFL)
|
||||||
|
QXR = (KVR, TQK)
|
||||||
|
HJR = (QJH, XJR)
|
||||||
|
BFS = (GQN, DKN)
|
||||||
|
TKX = (BFM, TRJ)
|
||||||
|
DGV = (BDS, XML)
|
||||||
|
DRG = (FRX, DMN)
|
||||||
|
VNX = (CNG, PPJ)
|
||||||
|
CSC = (MDV, KHP)
|
||||||
|
KMQ = (PJT, NXK)
|
||||||
|
DVP = (SCS, JTS)
|
||||||
|
LDF = (XMX, GKG)
|
||||||
|
QFH = (MTX, VRF)
|
||||||
|
RTT = (PQS, GBD)
|
||||||
|
KXR = (BDH, BDH)
|
||||||
|
SMD = (GHT, GGM)
|
||||||
|
TMB = (DMH, JJX)
|
||||||
|
KHP = (FHM, MGD)
|
||||||
|
TLF = (QMB, VNX)
|
||||||
|
FRK = (VTP, XSF)
|
||||||
|
KTL = (CHX, XSR)
|
||||||
|
GRH = (RLK, MSX)
|
||||||
|
QMD = (NHV, HXL)
|
||||||
|
KDV = (VRX, NXX)
|
||||||
|
LGQ = (VKF, PBK)
|
||||||
|
FVL = (BLX, LFP)
|
||||||
|
MMT = (NQQ, KSL)
|
||||||
|
CKP = (HJQ, HGC)
|
||||||
|
STH = (BKP, GLT)
|
||||||
|
QBK = (FPQ, VBV)
|
||||||
|
CTX = (FMN, PJN)
|
||||||
|
HHQ = (GBH, MQD)
|
||||||
|
JHV = (PXG, JPL)
|
||||||
|
FJC = (GKF, SMC)
|
||||||
|
TMG = (PFG, KTK)
|
||||||
|
XXG = (CRC, FGM)
|
||||||
|
BDH = (PBB, PBB)
|
||||||
|
FPQ = (CPP, LVR)
|
||||||
|
BKL = (BCJ, TDR)
|
||||||
|
GKG = (DSL, CTX)
|
||||||
|
LVL = (NDB, QSD)
|
||||||
|
BNH = (QJH, XJR)
|
||||||
|
TBG = (JVR, CPL)
|
||||||
|
CQH = (HNX, DSR)
|
||||||
|
VXD = (TKF, PMD)
|
||||||
|
MGR = (TRM, GJQ)
|
||||||
|
PDJ = (GLB, TFR)
|
||||||
|
HXB = (DCT, TMN)
|
||||||
|
XSM = (SQM, VDN)
|
||||||
|
HDR = (XPG, GBN)
|
||||||
|
GFQ = (XPH, DLP)
|
||||||
|
XKC = (PQS, GBD)
|
||||||
|
SBN = (TPQ, CDH)
|
||||||
|
RSX = (LFV, FQF)
|
||||||
|
PVP = (XNB, MLT)
|
||||||
|
LDG = (VMG, SDQ)
|
||||||
|
LXV = (LKL, GMK)
|
||||||
|
TKT = (SNC, LGQ)
|
||||||
|
SHX = (XDS, VFV)
|
||||||
|
GRG = (FQF, LFV)
|
||||||
|
QQV = (RST, SPD)
|
||||||
|
CNX = (NQQ, KSL)
|
||||||
|
DMX = (LVL, QGX)
|
||||||
|
CRC = (TVK, TNS)
|
||||||
|
JXP = (FFR, NCG)
|
||||||
|
BJC = (RGL, RMX)
|
||||||
|
BFT = (XQP, BMB)
|
||||||
|
SKV = (JFR, HXB)
|
||||||
|
JDB = (QGF, RBJ)
|
||||||
|
XRK = (NGR, MGG)
|
||||||
|
FXN = (JCV, VSK)
|
||||||
|
JJQ = (JSJ, BFS)
|
||||||
|
DDN = (BKP, GLT)
|
||||||
|
QBH = (XNX, CKR)
|
||||||
|
MLT = (PGQ, QFH)
|
||||||
|
SNC = (VKF, PBK)
|
||||||
|
FTN = (HDB, PQP)
|
||||||
|
DPL = (LSL, FXH)
|
||||||
|
TFS = (DPR, PVJ)
|
||||||
|
HVQ = (SPX, GVJ)
|
||||||
|
JJX = (NHF, JKM)
|
||||||
|
KVR = (HTP, NCR)
|
||||||
|
MQR = (SND, HMN)
|
||||||
|
MDD = (PFG, KTK)
|
||||||
|
PCB = (RXT, RXT)
|
||||||
|
NLT = (GBS, JLR)
|
||||||
|
GBD = (SMD, PJR)
|
||||||
|
NHV = (BXS, FDM)
|
||||||
|
GHT = (KLV, PTG)
|
||||||
|
SDQ = (LSX, FPH)
|
||||||
|
TRJ = (QXR, MVF)
|
||||||
|
HGC = (TPM, SVM)
|
||||||
|
MHQ = (JCS, MBJ)
|
||||||
|
CKX = (HPS, HPS)
|
||||||
|
SQM = (MXJ, QBK)
|
||||||
|
PQG = (PPL, PSM)
|
||||||
|
JRL = (CRL, XGS)
|
||||||
|
NRG = (DRD, SPP)
|
||||||
|
GHD = (NCG, FFR)
|
||||||
|
LBF = (PQP, HDB)
|
||||||
|
MKK = (KNN, PKP)
|
||||||
|
CPG = (RHF, BRD)
|
||||||
|
SQB = (KKT, CQR)
|
||||||
|
VKQ = (THT, KBB)
|
||||||
|
KFK = (FMQ, CVF)
|
||||||
|
PJR = (GHT, GGM)
|
||||||
|
FXH = (JSB, VPL)
|
||||||
|
JPQ = (PVG, DHJ)
|
||||||
|
PDB = (SKN, RMF)
|
||||||
|
JKX = (VXD, SGB)
|
||||||
|
DTB = (HQR, BJC)
|
||||||
|
VCG = (QLV, SFJ)
|
||||||
|
KVM = (SBN, VVF)
|
||||||
|
QXS = (TCF, JCC)
|
||||||
|
CJK = (BLD, TNX)
|
||||||
|
PKP = (VPB, XLQ)
|
||||||
|
JMG = (LSL, FXH)
|
||||||
|
FRX = (JRQ, TPT)
|
||||||
|
KFF = (FKG, NLT)
|
||||||
|
DPB = (RHC, KMQ)
|
||||||
|
SCB = (KJG, RHX)
|
||||||
|
DHN = (XJC, SBH)
|
||||||
|
QLH = (GPC, BVB)
|
||||||
|
PMX = (DRL, SRN)
|
||||||
|
XMK = (HFK, MJQ)
|
||||||
|
NDB = (JHV, JKP)
|
||||||
|
LQS = (TCN, FLS)
|
||||||
|
PGG = (NJD, QCG)
|
||||||
72
day_08/src/lib.rs
Normal file
72
day_08/src/lib.rs
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
use nom::{
|
||||||
|
bytes::complete::{take_until, take, tag},
|
||||||
|
character::complete::{
|
||||||
|
newline, multispace1, alphanumeric1,
|
||||||
|
},
|
||||||
|
sequence::{preceded, separated_pair},
|
||||||
|
multi::separated_list1,
|
||||||
|
IResult,
|
||||||
|
};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::str::Chars;
|
||||||
|
|
||||||
|
fn parse_mapline(input: &str) -> IResult<&str, (&str, (&str, &str))> {
|
||||||
|
let (input, start) = take(3 as usize)(input)?;
|
||||||
|
let (input, (left, right)) = preceded(tag(" = ("), separated_pair(alphanumeric1, tag(", "), alphanumeric1))(input)?;
|
||||||
|
Ok((input, (start, (left, right))))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn part1(input: &str) -> String {
|
||||||
|
let mut lines = input.lines();
|
||||||
|
let instructions = lines.next().unwrap().chars();
|
||||||
|
let map = lines.skip(1).map(|line| {
|
||||||
|
parse_mapline(line).unwrap().1
|
||||||
|
}).collect::<HashMap<&str, (&str, &str)>>();
|
||||||
|
let mut total_steps = 0;
|
||||||
|
let mut position = "AAA";
|
||||||
|
for _ in 0..100 {
|
||||||
|
for instruction in instructions.clone() {
|
||||||
|
total_steps += 1;
|
||||||
|
let (left, right) = map.get(position).unwrap();
|
||||||
|
if instruction == 'L' {
|
||||||
|
position = left;
|
||||||
|
} else {
|
||||||
|
position = right;
|
||||||
|
}
|
||||||
|
if position == "ZZZ" { return total_steps.to_string(); };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
total_steps.to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn part2(input: &str) -> String {
|
||||||
|
let mut lines = input.lines();
|
||||||
|
let instructions = lines.next().unwrap().chars();
|
||||||
|
let map = lines.skip(1).map(|line| {
|
||||||
|
parse_mapline(line).unwrap().1
|
||||||
|
}).collect::<HashMap<&str, (&str, &str)>>();
|
||||||
|
let start_nodes = map.keys().into_iter().filter(|x| x.chars().last().unwrap() == 'A').collect::<Vec<_>>();
|
||||||
|
let mut total_steps = 0;
|
||||||
|
let mut positions = start_nodes;
|
||||||
|
for _ in 0..10000000 {
|
||||||
|
for instruction in instructions.clone() {
|
||||||
|
total_steps += 1;
|
||||||
|
for i in 0..positions.len() {
|
||||||
|
let (left, right) = map.get(positions[i]).unwrap();
|
||||||
|
if instruction == 'L' {
|
||||||
|
positions[i] = &left;
|
||||||
|
} else {
|
||||||
|
positions[i] = &right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if positions.iter().all(|x| {x.chars().last().unwrap() == 'Z'}) { return total_steps.to_string(); };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
total_steps.to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod prelude {
|
||||||
|
pub use super::part1;
|
||||||
|
pub use super::part2;
|
||||||
|
}
|
||||||
|
|
||||||
48
day_08/src/main.rs
Normal file
48
day_08/src/main.rs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
use day_08::prelude::*;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let input = include_str!("../input.txt");
|
||||||
|
println!("{}", part1(input));
|
||||||
|
println!("{}", part2(input));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part1() {
|
||||||
|
let test_input = "RL
|
||||||
|
|
||||||
|
AAA = (BBB, CCC)
|
||||||
|
BBB = (DDD, EEE)
|
||||||
|
CCC = (ZZZ, GGG)
|
||||||
|
DDD = (DDD, DDD)
|
||||||
|
EEE = (EEE, EEE)
|
||||||
|
GGG = (GGG, GGG)
|
||||||
|
ZZZ = (ZZZ, ZZZ)";
|
||||||
|
assert_eq!(part1(test_input), "2".to_string());
|
||||||
|
let new_test_input = "LLR
|
||||||
|
|
||||||
|
AAA = (BBB, BBB)
|
||||||
|
BBB = (AAA, ZZZ)
|
||||||
|
ZZZ = (ZZZ, ZZZ)";
|
||||||
|
assert_eq!(part1(new_test_input), "6".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_part2() {
|
||||||
|
let test_input = "LR
|
||||||
|
|
||||||
|
11A = (11B, XXX)
|
||||||
|
11B = (XXX, 11Z)
|
||||||
|
11Z = (11B, XXX)
|
||||||
|
22A = (22B, XXX)
|
||||||
|
22B = (22C, 22C)
|
||||||
|
22C = (22Z, 22Z)
|
||||||
|
22Z = (22B, 22B)
|
||||||
|
XXX = (XXX, XXX)";
|
||||||
|
assert_eq!(part2(test_input), "6".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user