Solved Part 1

This commit is contained in:
apio 2022-12-01 18:37:10 +01:00
parent 81c7bff2d3
commit f95bd1267f
2 changed files with 2274 additions and 2 deletions

2251
src/input.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,24 @@
fn main() {
println!("Hello, world!");
// https://adventofcode.com/2022/day/1
const DATA: &'static str = include_str!("input.txt");
fn part1() {
let mut highest_sum = 0;
for elf in DATA.split("\n\n")
{
let mut elf_sum = 0;
for food_item in elf.split("\n")
{
elf_sum += food_item.parse().unwrap_or(0);
}
if elf_sum > highest_sum {
highest_sum = elf_sum;
}
}
println!("The elf carrying the most calories carries {} calories", highest_sum);
}
fn main()
{
part1();
}