Skip to content

Commit

Permalink
util
Browse files Browse the repository at this point in the history
  • Loading branch information
1adept committed Dec 21, 2023
1 parent e9f659f commit 8a775a9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use std::{fs, path::Path};

pub type Solution = (usize, usize);

pub trait Day {
fn solve(input: &str) -> Solution;
}

///
/// Read data for a specific day
/// ---
/// It is assumed that the data file is formatted as input_dd.txt
/// # Errors
///
/// This function will return an error if .
pub fn read_input(day: u8) -> Result<String, std::io::Error> {
const BASE_PATH: &str = "../data";
let path = format!("{BASE_PATH}/input_{day:02}.txt");
let path = Path::new(&path);
println!("{path:?}");
fs::read_to_string(path)
}

0 comments on commit 8a775a9

Please sign in to comment.