Simplification
authorGreg Burri <greg.burri@gmail.com>
Sun, 11 Dec 2022 12:21:42 +0000 (13:21 +0100)
committerGreg Burri <greg.burri@gmail.com>
Sun, 11 Dec 2022 12:21:42 +0000 (13:21 +0100)
src/day11.rs

index 9ad00bd..75a64af 100644 (file)
@@ -85,8 +85,7 @@ pub fn run(monkeys: &mut [Monkey], nb_rounds: u64, worry_divided: u64) -> u64 {
         }
     }
 
-    let most_inspected_items: Vec<&u64> = inspected.iter().sorted().rev().take(2).collect();
-    most_inspected_items[0] * most_inspected_items[1]
+    inspected.iter().sorted().rev().take(2).product()
 }
 
 #[cfg(test)]