From fceda8ac1b6b00727b1b1b8e4cdc5078e59c73a2 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 6 Dec 2021 11:53:34 +0100 Subject: [PATCH] 2021: day06: use rotate_left --- aoc2021/src/day06.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/aoc2021/src/day06.rs b/aoc2021/src/day06.rs index 3fae107..499531b 100644 --- a/aoc2021/src/day06.rs +++ b/aoc2021/src/day06.rs @@ -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 {