summaryrefslogtreecommitdiff
path: root/2020
diff options
context:
space:
mode:
Diffstat (limited to '2020')
-rw-r--r--2020/rust/Cargo.toml1
-rw-r--r--2020/rust/day01/Cargo.toml1
-rw-r--r--2020/rust/day01/src/main.rs36
3 files changed, 23 insertions, 15 deletions
diff --git a/2020/rust/Cargo.toml b/2020/rust/Cargo.toml
index 9674b94..ee71f9e 100644
--- a/2020/rust/Cargo.toml
+++ b/2020/rust/Cargo.toml
@@ -1,5 +1,6 @@
[workspace]
members = [
+ "aoc",
"day01",
# "day02",
# "day03",
diff --git a/2020/rust/day01/Cargo.toml b/2020/rust/day01/Cargo.toml
index 674217d..4bf07f8 100644
--- a/2020/rust/day01/Cargo.toml
+++ b/2020/rust/day01/Cargo.toml
@@ -5,4 +5,5 @@ authors = ["cos <cos>"]
edition = "2018"
[dependencies]
+aoc = { path = "../aoc" }
anyhow = "1.0"
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),
}