Update solution for 2022 day 01

Rename binaries to match the other days
This commit is contained in:
Patrick Auernig 2022-12-07 22:59:58 +01:00
parent 1cb8db79d6
commit 500d952ee3
3 changed files with 6 additions and 4 deletions

View File

@ -1,5 +1,5 @@
@part PART INPUT_FILE="inputs/puzzle.txt": @part PART INPUT_FILE="inputs/puzzle.txt":
cargo run --bin part{{PART}} -- {{INPUT_FILE}} cargo run --bin part_{{PART}} -- {{INPUT_FILE}}
clean: clean:
cargo clean cargo clean

View File

@ -4,8 +4,9 @@ fn main() -> io::Result<()> {
let infile_path = env::args().nth(1).expect("input file"); let infile_path = env::args().nth(1).expect("input file");
let sums = aoc_2022_01::input_sums(infile_path)?; let sums = aoc_2022_01::input_sums(infile_path)?;
let max = sums.max().unwrap(); if let Some(max) = sums.max() {
println!("{max}"); println!("{max}");
}
Ok(()) Ok(())
} }

View File

@ -4,7 +4,8 @@ fn main() -> io::Result<()> {
let infile_path = env::args().nth(1).expect("input file"); let infile_path = env::args().nth(1).expect("input file");
let mut sums = aoc_2022_01::input_sums(infile_path)?.collect::<Vec<_>>(); let mut sums = aoc_2022_01::input_sums(infile_path)?.collect::<Vec<_>>();
sums.sort_by(|a, b| b.partial_cmp(a).unwrap()); sums.sort_by(|a, b| b.cmp(a));
let three_highest_sum: &u32 = &sums[..3].iter().sum(); let three_highest_sum: &u32 = &sums[..3].iter().sum();
println!("{three_highest_sum}"); println!("{three_highest_sum}");