mirror of
https://github.com/SebastianStork/advent-of-code.git
synced 2026-01-21 12:11:34 +01:00
2025/day-04: Remove unnecessary loop
This commit is contained in:
parent
d8780f97a7
commit
ff3c082979
1 changed files with 5 additions and 13 deletions
|
|
@ -114,19 +114,11 @@ fn number_of_accessible_rolls(rolls: &[Rc<RefCell<Roll>>]) -> usize {
|
|||
}
|
||||
|
||||
fn number_of_removeable_rolls(rolls: &[Rc<RefCell<Roll>>]) -> usize {
|
||||
loop {
|
||||
let deleted_any = rolls
|
||||
rolls
|
||||
.iter()
|
||||
.filter(|roll| !roll.borrow().deleted)
|
||||
.filter(|roll| roll.borrow().is_accessible())
|
||||
.inspect(|roll| Roll::delete(roll))
|
||||
.count()
|
||||
> 0;
|
||||
|
||||
if !deleted_any {
|
||||
break;
|
||||
}
|
||||
}
|
||||
.for_each(Roll::delete);
|
||||
|
||||
rolls.iter().filter(|roll| roll.borrow().deleted).count()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue