mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-25 23:04:17 -05:00
refactor(arc1): improve readability by using functional style
This commit is contained in:
parent
0b7f3fe37a
commit
92a5d0037f
1 changed files with 1 additions and 6 deletions
|
@ -32,12 +32,7 @@ fn main() {
|
|||
for offset in 0..8 {
|
||||
let child_numbers = // TODO
|
||||
joinhandles.push(thread::spawn(move || {
|
||||
let mut i = offset;
|
||||
let mut sum = 0;
|
||||
while i < child_numbers.len() {
|
||||
sum += child_numbers[i];
|
||||
i += 8;
|
||||
}
|
||||
let sum: u32 = child_numbers.iter().filter(|n| *n % 8 == offset).sum();
|
||||
println!("Sum of offset {} is {}", offset, sum);
|
||||
}));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue