diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2023-12-05 15:36:09 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2023-12-05 15:36:09 +0200 |
| commit | 5cc25461680938d03f345ca1dfab61c2ef95cca3 (patch) | |
| tree | ad642a490321d0ceffabac56817a338d85bcd32d /2023/Rust/src/day4.rs | |
| parent | 7e7fcbc6990721176ed10886f585505f98cc2191 (diff) | |
| download | aoc-5cc25461680938d03f345ca1dfab61c2ef95cca3.tar.xz aoc-5cc25461680938d03f345ca1dfab61c2ef95cca3.zip | |
Part 1 day5 done
Diffstat (limited to '2023/Rust/src/day4.rs')
| -rw-r--r-- | 2023/Rust/src/day4.rs | 8 |
1 files changed, 2 insertions, 6 deletions
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<ScratchCard> = 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)) |
