diff --git a/Cargo.toml b/Cargo.toml index 1c8cb9b..367d19c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,4 +9,3 @@ edition = "2021" [[bin]] name = "d1p1" -path = "src/d1p1.rs" diff --git a/src/bin/d1p1.rs b/src/bin/d1p1.rs new file mode 100644 index 0000000..1d36091 --- /dev/null +++ b/src/bin/d1p1.rs @@ -0,0 +1,8 @@ +use aoc22::day1; + +fn main() { + let elves = day1::read_elves(); + + let max = elves.iter().max().unwrap(); + println!("The elf with the most calories is carrying {} cal", max); +} diff --git a/src/d1p1.rs b/src/day1.rs similarity index 83% rename from src/d1p1.rs rename to src/day1.rs index c285b36..e4cfa76 100644 --- a/src/d1p1.rs +++ b/src/day1.rs @@ -1,6 +1,6 @@ use std::io; -fn main() { +pub fn read_elves() -> Vec { println!("What's the calorie list?"); let lines = io::stdin().lines(); let mut was_empty = false; @@ -23,6 +23,5 @@ fn main() { elves.push(prev_calories + calories); } - let max = elves.iter().max().unwrap(); - println!("The elf with the most calories is carrying {} cal", max); + elves } diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..8b2a328 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1 @@ +pub mod day1;