From 5cc25461680938d03f345ca1dfab61c2ef95cca3 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Tue, 5 Dec 2023 15:36:09 +0200 Subject: Part 1 day5 done --- 2023/Rust/src/day4.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to '2023/Rust/src/day4.rs') diff --git a/2023/Rust/src/day4.rs b/2023/Rust/src/day4.rs index 51e2198..59c8cfc 100644 --- a/2023/Rust/src/day4.rs +++ b/2023/Rust/src/day4.rs @@ -42,12 +42,8 @@ impl From<&str> for ScratchCard { } fn solve_part_one(data: &str) -> u32 { - let mut scratch_cards: Vec = vec![]; - for line in data.lines() { - scratch_cards.push(ScratchCard::from(line)) - } - scratch_cards - .iter() + data.lines() + .map(|line| ScratchCard::from(line)) .map(|card| card.get_matching()) .filter(|x| *x > 0) .map(|x| 2_u32.pow(std::cmp::max(x - 1, 0) as u32)) -- cgit v1.2.3