24 lines
567 B
Rust
24 lines
567 B
Rust
use std::fs;
|
|
|
|
pub fn day_1() -> String {
|
|
let input = fs::read_to_string("input/day_1.txt").unwrap();
|
|
|
|
let elves: Vec<&str> = input.split("\n\n").collect();
|
|
|
|
let mut highest_calorie_count: u64 = 0;
|
|
|
|
for meals in elves.iter() {
|
|
let mut elf_calorie_count= 0;
|
|
|
|
for meal in meals.split_whitespace() {
|
|
elf_calorie_count += meal.parse().unwrap_or(0);
|
|
}
|
|
|
|
if elf_calorie_count > highest_calorie_count {
|
|
highest_calorie_count = elf_calorie_count;
|
|
}
|
|
}
|
|
|
|
format!("{highest_calorie_count}")
|
|
}
|