day1: Extract input parsing to lib
This commit is contained in:
@ -9,4 +9,3 @@ edition = "2021"
|
|||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "d1p1"
|
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;
|
use std::io;
|
||||||
|
|
||||||
fn main() {
|
pub fn read_elves() -> Vec<u32> {
|
||||||
println!("What's the calorie list?");
|
println!("What's the calorie list?");
|
||||||
let lines = io::stdin().lines();
|
let lines = io::stdin().lines();
|
||||||
let mut was_empty = false;
|
let mut was_empty = false;
|
||||||
@ -23,6 +23,5 @@ fn main() {
|
|||||||
elves.push(prev_calories + calories);
|
elves.push(prev_calories + calories);
|
||||||
}
|
}
|
||||||
|
|
||||||
let max = elves.iter().max().unwrap();
|
elves
|
||||||
println!("The elf with the most calories is carrying {} cal", max);
|
|
||||||
}
|
}
|
||||||
1
src/lib.rs
Normal file
1
src/lib.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod day1;
|
||||||
Reference in New Issue
Block a user