day1: Extract input parsing to lib
This commit is contained in:
parent
f7fe704a12
commit
84ee26264b
@ -9,4 +9,3 @@ edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "d1p1"
|
||||
path = "src/d1p1.rs"
|
||||
|
8
src/bin/d1p1.rs
Normal file
8
src/bin/d1p1.rs
Normal file
@ -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);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
use std::io;
|
||||
|
||||
fn main() {
|
||||
pub fn read_elves() -> Vec<u32> {
|
||||
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
|
||||
}
|
1
src/lib.rs
Normal file
1
src/lib.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod day1;
|
Loading…
x
Reference in New Issue
Block a user