diff --git a/2023/Cargo.toml b/2023/Cargo.toml index 25340ba..d7395b2 100644 --- a/2023/Cargo.toml +++ b/2023/Cargo.toml @@ -8,6 +8,7 @@ fnv = "1.0.7" impl_ops = "0.1.1" itertools = "0.12" paste = "1.0" +tuple-map = "0.4.0" [profile.bench] lto = true diff --git a/2023/src/bin/day04.rs b/2023/src/bin/day04.rs index df75c5e..a0494a6 100644 --- a/2023/src/bin/day04.rs +++ b/2023/src/bin/day04.rs @@ -1,18 +1,14 @@ #![feature(test, try_blocks)] extern crate test; use aoc2023::{boilerplate, common::*}; +use tuple_map::TupleMap2; const DAY: usize = 4; type I = u32; type Parsed = Vec<(Vec, Vec)>; fn parse_input(raw: &str) -> Parsed { - raw.lines() - .filter_map(|l| { - let (w, m) = l.after(": ").split_once(" | ")?; - Some((w.split_whitespace().map(parse_num).collect(), m.split_whitespace().map(parse_num).collect())) - }) - .collect() + raw.lines().filter_map(|l| Some(l.after(": ").split_once(" | ")?.map(|ns| ns.split_whitespace().map(parse_num).collect()))).collect() } fn winning_numbers((winning, mine): &(Vec, Vec)) -> usize {