Day 2 Part 2 Complete :)

This commit is contained in:
Luke Else 2023-12-04 18:52:58 +00:00
parent 6bd170cbde
commit 34c8099720

View File

@ -1,4 +1,4 @@
use std::{borrow::BorrowMut, collections::HashMap}; use std::{borrow::BorrowMut, collections::HashMap, fs::copy, vec};
use super::Solution; use super::Solution;
@ -37,20 +37,23 @@ impl Solution for Day04 {
.enumerate() .enumerate()
.collect(); .collect();
for card in cards {} let mut copy_counts: Vec<u32> = vec![1; cards.len()];
// for (i, card) in cards.iter() {
// let winning_nums = self.get_count_winning_numbers(card)?; for (i, card) in cards.iter() {
// if winning_nums == 0 { // Create a container for the cards
// continue;
// } // Check if we are looking at a winning card
// for c in cards.clone()[(i + 1)..=(i + 1 + winning_nums)].iter() { let winning_nums = self.get_count_winning_numbers(card)?;
// cards.push(c.clone()); if winning_nums == 0 { continue; }
// }
// } // We have a winning card... add the next cards resulting * num of current card
// for i in cards.clone() { for j in 0..winning_nums {
// println!("{:?}", i); // Don't let us add cards that aren't available
// } copy_counts[*i + j + 1] += copy_counts[*i];
Ok(Box::new(cards.len())) }
}
Ok(Box::new(copy_counts.iter().sum::<u32>()))
} }
fn get_day(&self) -> u8 { fn get_day(&self) -> u8 {