2019 - day1 - part 2: use ref instatt pointer
This commit is contained in:
parent
d9f9fb48ed
commit
8a201e8aa0
1 changed files with 3 additions and 3 deletions
|
@ -12,14 +12,14 @@ fn main() {
|
|||
];
|
||||
|
||||
let mut result = 0;
|
||||
for i in all_modules.iter() {
|
||||
result += fuel_calc(*i);
|
||||
for &i in all_modules.iter() {
|
||||
result += fuel_calc(i);
|
||||
}
|
||||
println!("Part1: I need {} fuel for all modules", result);
|
||||
|
||||
//all_modules.map(fuel_calc).sum()
|
||||
//all_modules.map(fuel_calc).sum()
|
||||
println!("Part2: I need {} fuel for all modules", all_modules.iter().fold(0, |sum, x | fuel_tyranny(*x) + sum ));
|
||||
println!("Part2: I need {} fuel for all modules", all_modules.iter().fold(0, |sum, &x | fuel_tyranny(x) + sum ));
|
||||
}
|
||||
|
||||
fn fuel_calc(mass: i32) -> i32 {
|
||||
|
|
Loading…
Reference in a new issue