summaryrefslogtreecommitdiff
path: root/2024_rust/src/lib.rs
diff options
context:
space:
mode:
authorGuillermo Ramos2024-12-12 17:31:29 +0100
committerGuillermo Ramos2024-12-13 09:10:55 +0100
commitca02218365f8fcb05e29c312ba5ede515bbc5310 (patch)
tree8ee0ec6958ee664942bfb25131f30a0d0733983c /2024_rust/src/lib.rs
parent94abe97596828b0fa5ba79a3ba1cc76720c53994 (diff)
downloadAoC-ca02218365f8fcb05e29c312ba5ede515bbc5310.tar.gz
2024.12
Diffstat (limited to '2024_rust/src/lib.rs')
-rw-r--r--2024_rust/src/lib.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/2024_rust/src/lib.rs b/2024_rust/src/lib.rs
index ea6f7d6..db67f27 100644
--- a/2024_rust/src/lib.rs
+++ b/2024_rust/src/lib.rs
@@ -60,15 +60,24 @@ pub mod matrix {
}
}
-pub fn run_day<S1, S2>(day: &str, p1: S1, p2: S2)
+pub fn read_input(day: &str) -> String {
+ let input_file = format!("inputs/{day}");
+ std::fs::read_to_string(input_file).unwrap()
+}
+
+pub fn run_day<S1, S2>(day: &str, p1: S1, p2: S2) -> (String, String)
where
S1: FnOnce(&str) -> String,
S2: FnOnce(&str) -> String,
{
- let input_file = format!("inputs/{day}");
- let input = std::fs::read_to_string(input_file).unwrap();
+ let input = read_input(day);
+
+ let p1r = p1(&input);
+ let p2r = p2(&input);
println!("==== DAY {day}");
- println!("Result (P1): {}", p1(&input));
- println!("Result (P2): {}", p2(&input));
+ println!("Result (P1): {}", p1r);
+ println!("Result (P2): {}", p2r);
+
+ (p1r, p2r)
}