diff options
Diffstat (limited to '2020/rust/day01/src/main.rs')
-rw-r--r-- | 2020/rust/day01/src/main.rs | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/2020/rust/day01/src/main.rs b/2020/rust/day01/src/main.rs index 38f25d2..fb661e6 100644 --- a/2020/rust/day01/src/main.rs +++ b/2020/rust/day01/src/main.rs @@ -43,6 +43,8 @@ fn part2(input: &[usize]) -> Option<usize> { } fn main() { + let ( do_part_1, do_part_2 ) = aoc::do_parts(); + let filename = match args().nth(1) { Some(f) => f, None => { @@ -50,22 +52,26 @@ fn main() { std::process::exit(1); }, }; - match read_input(filename) { + match read_input(filename) { Ok(input) => { - match part1(&input) { - Some(solution) => println!("Part1, product found to be: {}", solution), - None => { - eprintln!("Part1, no solution found"); - std::process::exit(1); - } - }; - match part2(&input) { - Some(solution) => println!("Part2, product found to be: {}", solution), - None => { - eprintln!("Part2, no solution found"); - std::process::exit(1); - } - }; + if do_part_1 { + match part1(&input) { + Some(solution) => println!("Part1, product found to be: {}", solution), + None => { + eprintln!("Part1, no solution found"); + std::process::exit(1); + } + }; + } + if do_part_2 { + match part2(&input) { + Some(solution) => println!("Part2, product found to be: {}", solution), + None => { + eprintln!("Part2, no solution found"); + std::process::exit(1); + } + }; + } }, Err(err) => eprintln!("Could not read input: {}", err), } |