3 ms·
fn main() { let mut sum = 0i64; for _ in 0..200 { let items = (0..1000000).zip(1..1000000).map(|(a, b)| a + b); sum = it
by masklinn 11y ago
fn main() {
let mut sum = 0i64;
for _ in 0..200 {
let items = (0..1000000).zip(1..1000000).map(|(a, b)| a + b);
sum = items.enumerate().filter(|&(i, _)| i % 100 == 0).fold(0, |acc, (_, v)| acc + v);
}
println!("{}", sum);
}
(note that the addition part does some extra work since it iterates on the whole source instead of skipping ahead)