2025/day-04: Remove unnecessary loop

This commit is contained in:
SebastianStork 2025-12-05 10:20:54 +01:00
parent d8780f97a7
commit ff3c082979
Signed by: SebastianStork
SSH key fingerprint: SHA256:iEM011ogNMG1q8+U500adGu/9rpPuZ2KnFtbdLeqTiI

View file

@ -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
.iter()
.filter(|roll| !roll.borrow().deleted)
.filter(|roll| roll.borrow().is_accessible())
.inspect(|roll| Roll::delete(roll))
.count()
> 0;
if !deleted_any {
break;
}
}
rolls
.iter()
.filter(|roll| !roll.borrow().deleted)
.filter(|roll| roll.borrow().is_accessible())
.for_each(Roll::delete);
rolls.iter().filter(|roll| roll.borrow().deleted).count()
}