add tuple_map
This commit is contained in:
parent
44fa3dc40f
commit
3ec8057f64
@ -8,6 +8,7 @@ fnv = "1.0.7"
|
|||||||
impl_ops = "0.1.1"
|
impl_ops = "0.1.1"
|
||||||
itertools = "0.12"
|
itertools = "0.12"
|
||||||
paste = "1.0"
|
paste = "1.0"
|
||||||
|
tuple-map = "0.4.0"
|
||||||
|
|
||||||
[profile.bench]
|
[profile.bench]
|
||||||
lto = true
|
lto = true
|
||||||
|
@ -1,18 +1,14 @@
|
|||||||
#![feature(test, try_blocks)]
|
#![feature(test, try_blocks)]
|
||||||
extern crate test;
|
extern crate test;
|
||||||
use aoc2023::{boilerplate, common::*};
|
use aoc2023::{boilerplate, common::*};
|
||||||
|
use tuple_map::TupleMap2;
|
||||||
|
|
||||||
const DAY: usize = 4;
|
const DAY: usize = 4;
|
||||||
type I = u32;
|
type I = u32;
|
||||||
type Parsed = Vec<(Vec<I>, Vec<I>)>;
|
type Parsed = Vec<(Vec<I>, Vec<I>)>;
|
||||||
|
|
||||||
fn parse_input(raw: &str) -> Parsed {
|
fn parse_input(raw: &str) -> Parsed {
|
||||||
raw.lines()
|
raw.lines().filter_map(|l| Some(l.after(": ").split_once(" | ")?.map(|ns| ns.split_whitespace().map(parse_num).collect()))).collect()
|
||||||
.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()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn winning_numbers((winning, mine): &(Vec<I>, Vec<I>)) -> usize {
|
fn winning_numbers((winning, mine): &(Vec<I>, Vec<I>)) -> usize {
|
||||||
|
Loading…
Reference in New Issue
Block a user