Solved Part 1
This commit is contained in:
parent
81c7bff2d3
commit
f95bd1267f
2251
src/input.txt
Normal file
2251
src/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
25
src/main.rs
25
src/main.rs
@ -1,3 +1,24 @@
|
|||||||
fn main() {
|
// https://adventofcode.com/2022/day/1
|
||||||
println!("Hello, world!");
|
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user