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};
|
use two::{two_one, two_two};
|
||||||
|
|
||||||
fn main() -> Result<(), AdventError> {
|
fn main() -> Result<(), AdventError> {
|
||||||
one_one()?;
|
//one_one()?;
|
||||||
one_two()?;
|
//one_two()?;
|
||||||
two_one()?;
|
two_one()?;
|
||||||
Ok(two_two()?)
|
Ok(two_two()?)
|
||||||
}
|
}
|
||||||
|
@ -87,20 +87,17 @@ pub fn two_one() -> Result<(), AdventError> {
|
|||||||
let max_blue = 14;
|
let max_blue = 14;
|
||||||
|
|
||||||
for game in games.iter() {
|
for game in games.iter() {
|
||||||
let mut valid: bool = true;
|
if game.pulls.iter().all(|pull| {
|
||||||
for pull in game.pulls.iter() {
|
pull.groups.iter().all(|group| {
|
||||||
for group in pull.groups.iter() {
|
|
||||||
match group.color {
|
match group.color {
|
||||||
Color::Red => if group.count > max_red { valid = false },
|
Color::Red => group.count <= max_red,
|
||||||
Color::Green => if group.count > max_green { valid = false },
|
Color::Green => group.count <= max_green,
|
||||||
Color::Blue => if group.count > max_blue { valid = false },
|
Color::Blue => group.count <= max_blue,
|
||||||
}
|
}
|
||||||
if valid == false { break };
|
})
|
||||||
}
|
}) {
|
||||||
if valid == false { break };
|
sum += game.id
|
||||||
valid = true;
|
|
||||||
}
|
}
|
||||||
if valid { sum += game.id }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(println!("{}", sum))
|
Ok(println!("{}", sum))
|
||||||
|
Loading…
Reference in New Issue
Block a user