well that was easy
This commit is contained in:
parent
ca360f7baa
commit
2fbc98de3d
@ -191,8 +191,21 @@ fn part1(boards: &[Board]) -> eyre::Result<Board> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn part2(boards: &[Board]) -> eyre::Result<Board> {
|
||||||
|
let winner = boards.iter()
|
||||||
|
.filter(|b| b.bingo_time.is_some())
|
||||||
|
.max_by_key(|b| b.bingo_time.unwrap());
|
||||||
|
|
||||||
|
match winner {
|
||||||
|
Some(w) => Ok(*w),
|
||||||
|
None => Err(eyre!("Could not find a winning board")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn run(data: &str) -> eyre::Result<(isize, isize)> {
|
pub fn run(data: &str) -> eyre::Result<(isize, isize)> {
|
||||||
let boards = load(data)?;
|
let boards = load(data)?;
|
||||||
let winner = part1(&boards)?;
|
let winner = part1(&boards)?;
|
||||||
Ok((winner.score()?, 0))
|
let loser = part2(&boards)?;
|
||||||
|
Ok((winner.score()?, loser.score()?))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user