First half of Day 1 Finished.
This commit is contained in:
parent
9d0fc7d649
commit
2e000f683f
2 changed files with 7 additions and 6 deletions
|
@ -9,10 +9,8 @@ impl Elf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_inventory(& self)
|
pub fn get_total(& self) -> u64
|
||||||
{
|
{
|
||||||
for inv in &self.inventory {
|
self.inventory.iter().sum()
|
||||||
println!("{}",inv)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -45,8 +45,11 @@ fn main()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gathering all the total kcal onto a vector
|
||||||
|
let mut vec_total: Vec<u64> = Vec::new();
|
||||||
for elf in &vec_elf {
|
for elf in &vec_elf {
|
||||||
println!("Elf: ");
|
vec_total.push(elf.get_total());
|
||||||
elf.print_inventory();
|
|
||||||
}
|
}
|
||||||
|
// Printing the max
|
||||||
|
println!("Most Calories: {}", vec_total.iter().max().unwrap());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue