Finished day 2
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
fn elf_calorie_counts(input: &String) -> Vec<u64> {
|
||||
fn elf_calorie_counts(input: &str) -> Vec<u64> {
|
||||
input.split("\n\n").map(|elf| {
|
||||
elf.split_whitespace().map(|meal| meal.parse().unwrap_or(0)).sum()
|
||||
}).collect()
|
||||
}
|
||||
|
||||
pub fn part_1(input: &String) -> u64 {
|
||||
pub fn part_1(input: &str) -> u64 {
|
||||
let mut elf_calorie_counts= elf_calorie_counts(input);
|
||||
|
||||
elf_calorie_counts.sort_unstable();
|
||||
@@ -12,7 +12,7 @@ pub fn part_1(input: &String) -> u64 {
|
||||
elf_calorie_counts.pop().unwrap()
|
||||
}
|
||||
|
||||
pub fn part_2(input: &String) -> u64 {
|
||||
pub fn part_2(input: &str) -> u64 {
|
||||
let mut elf_calorie_counts= elf_calorie_counts(input);
|
||||
|
||||
elf_calorie_counts.sort_unstable();
|
||||
|
||||
Reference in New Issue
Block a user