feat: add read_file_part

This commit is contained in:
2023-12-08 08:00:44 +01:00
parent 00000160a1
commit 0000017058

View File

@@ -54,3 +54,14 @@ pub fn read_file(folder: &str, day: u8) -> String {
let f = fs::read_to_string(filepath);
f.expect("could not open input file").trim().to_string()
}
#[must_use]
pub fn read_file_part(folder: &str, day: u8, part: u8) -> String {
let cwd = env::current_dir().unwrap();
let filepath = cwd
.join("data")
.join(folder)
.join(format!("{day:02}-{part}.txt"));
let f = fs::read_to_string(filepath);
f.expect("could not open input file").trim().to_string()
}