@@ -19,6 +19,15 @@ pub fn read_file(folder: &str, day: Day) -> String {
|
||||
f.expect("could not open input file")
|
||||
}
|
||||
|
||||
/// Helper function that reads a text file to string, appending a part suffix. E.g. like `01-2.txt`.
|
||||
#[must_use]
|
||||
pub fn read_file_part(folder: &str, day: Day, part: u8) -> String {
|
||||
let cwd = env::current_dir().unwrap();
|
||||
let filepath = cwd.join("data").join(folder).join(format!("{day}-{part}.txt"));
|
||||
let f = fs::read_to_string(filepath);
|
||||
f.expect("could not open input file")
|
||||
}
|
||||
|
||||
/// Creates the constant `DAY` and sets up the input and runner for each part.
|
||||
#[macro_export]
|
||||
macro_rules! solution {
|
||||
|
||||
Reference in New Issue
Block a user