2021: day06: use rotate_left

This commit is contained in:
Antoine Martin 2021-12-06 11:53:34 +01:00
parent bb9265657b
commit fceda8ac1b

View file

@ -38,12 +38,9 @@ impl School {
fn next_turn(&mut self) {
let newly_spawned = self.fish_timers[0];
for i in 1..self.fish_timers.len() {
self.fish_timers[i - 1] = self.fish_timers[i];
}
self.fish_timers.rotate_left(1);
self.fish_timers[SPAWNING_DELAY - 1] += newly_spawned;
*self.fish_timers.last_mut().unwrap() = newly_spawned;
}
fn size(&self) -> usize {