refactor(arc1): improve readability by using functional style

This commit is contained in:
fointard 2022-04-19 17:11:27 +02:00
parent 0b7f3fe37a
commit 92a5d0037f
No known key found for this signature in database
GPG key ID: 7FC786FDA2727144

View file

@ -32,12 +32,7 @@ fn main() {
for offset in 0..8 { for offset in 0..8 {
let child_numbers = // TODO let child_numbers = // TODO
joinhandles.push(thread::spawn(move || { joinhandles.push(thread::spawn(move || {
let mut i = offset; let sum: u32 = child_numbers.iter().filter(|n| *n % 8 == offset).sum();
let mut sum = 0;
while i < child_numbers.len() {
sum += child_numbers[i];
i += 8;
}
println!("Sum of offset {} is {}", offset, sum); println!("Sum of offset {} is {}", offset, sum);
})); }));
} }