Some minor changes.
This commit is contained in:
parent
0ad7cd3587
commit
97bf3cdf5d
@ -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()?)
|
||||
}
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user