Some minor changes.

This commit is contained in:
Dennis Brentjes 2023-12-03 11:01:12 +01:00
parent 0ad7cd3587
commit 97bf3cdf5d
2 changed files with 10 additions and 13 deletions

View File

@ -8,8 +8,8 @@ use one::{one_one, one_two};
use two::{two_one, two_two};
fn main() -> Result<(), AdventError> {
one_one()?;
one_two()?;
//one_one()?;
//one_two()?;
two_one()?;
Ok(two_two()?)
}

View File

@ -87,20 +87,17 @@ pub fn two_one() -> Result<(), AdventError> {
let max_blue = 14;
for game in games.iter() {
let mut valid: bool = true;
for pull in game.pulls.iter() {
for group in pull.groups.iter() {
if game.pulls.iter().all(|pull| {
pull.groups.iter().all(|group| {
match group.color {
Color::Red => if group.count > max_red { valid = false },
Color::Green => if group.count > max_green { valid = false },
Color::Blue => if group.count > max_blue { valid = false },
Color::Red => group.count <= max_red,
Color::Green => group.count <= max_green,
Color::Blue => group.count <= max_blue,
}
if valid == false { break };
}
if valid == false { break };
valid = true;
})
}) {
sum += game.id
}
if valid { sum += game.id }
}
Ok(println!("{}", sum))