feat: add read_file_part

This commit is contained in:
Matej Janezic 2023-12-08 08:00:44 +01:00
parent 00000160a1
commit 0000017058
Signed by: janezicmatej
GPG Key ID: 4298E230ED37B2C0
1 changed files with 11 additions and 0 deletions

View File

@ -54,3 +54,14 @@ pub fn read_file(folder: &str, day: u8) -> String {
let f = fs::read_to_string(filepath); let f = fs::read_to_string(filepath);
f.expect("could not open input file").trim().to_string() 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()
}