diff --git a/Cargo.lock b/Cargo.lock index ee5de96..f8754b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,8 +69,6 @@ version = "0.1.0" dependencies = [ "aoc_libs", "itertools", - "once_cell", - "regex", ] [[package]] diff --git a/days/day07/Cargo.toml b/days/day07/Cargo.toml index e535201..3c8d1de 100644 --- a/days/day07/Cargo.toml +++ b/days/day07/Cargo.toml @@ -7,6 +7,4 @@ edition.workspace = true [dependencies] aoc_libs.workspace = true -regex.workspace = true -once_cell.workspace = true itertools.workspace = true diff --git a/days/day07/src/parse.rs b/days/day07/src/parse.rs index c0ac092..70818a1 100644 --- a/days/day07/src/parse.rs +++ b/days/day07/src/parse.rs @@ -1,6 +1,4 @@ use itertools::Itertools; -use once_cell::sync::Lazy; -use regex::Regex; #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)] pub enum Card { @@ -82,16 +80,13 @@ impl Hand { } } -static PARSE_REGEX: Lazy = - Lazy::new(|| Regex::new(r"^([AKQJT98765432]{5}) (\d+)$").unwrap()); - pub fn parse(input: &str) -> Vec<(Hand, u32)> { input .lines() .map(|line| { - let captures = PARSE_REGEX.captures(line).unwrap(); - let hand = &captures[1]; - let bid: u32 = captures[2].parse().unwrap(); + let mut splits = line.split(' '); + let hand = splits.next().unwrap(); + let bid: u32 = splits.next().unwrap().parse().unwrap(); let hand: Vec = hand .chars() .map(|c| match c { @@ -111,8 +106,7 @@ pub fn parse(input: &str) -> Vec<(Hand, u32)> { e => panic!("invalid card {}", e), }) .collect(); - let hand = Hand::new(hand.try_into().unwrap()); - (hand, bid) + (Hand::new(hand.try_into().unwrap()), bid) }) .collect() }