--- /dev/null
+# - create a new file src/day%
+# - update the main to integrate the new day
+new-day%:
+ if [ -f "src/$(subst new-,,$@).rs" ]; then return 1; fi
+ cp -v src/day00.rs src/$(subst new-,,$@).rs
+ sed -i \
+ -e "$$(( $$(grep -n main src/main.rs | cut -d ':' -f 1) - 2 ))a\pub mod $(subst new-,,$@);" \
+ -e "/_ =>/i\ \"$(subst new-,,$@)\" => $(subst new-,,$@)::run(\&input)?," \
+ src/main.rs
+
+# run the tests for a specific day
+test-day%:
+ cargo test $(subst test-,,$@)::tests
+
+# run a specific day with its input file
+day%:
+ cargo run $@ input/$@.txt
--- /dev/null
+use std::error::Error;
+use std::path::Path;
+
+pub fn run(input: &str) -> Result<(), Box<dyn Error>> {
+ let res = run_part1(&input)?;
+ println!("{res}");
+
+ let res = run_part2(&input)?;
+ println!("{res}");
+
+ Ok(())
+}
+
+fn get_day() -> String {
+ let filename = file!();
+ Path::new(filename).file_stem().unwrap().to_str().unwrap().to_string()
+}
+
+fn run_part1(input: &str) -> Result<u32, Box<dyn Error>> {
+ println!("Running {} - part 1", get_day());
+
+ Ok(0)
+}
+
+fn run_part2(input: &str) -> Result<u32, Box<dyn Error>> {
+ println!("Running {} - part 2", get_day());
+
+ Ok(0)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ static TEXT_INPUT: &str = "\
+";
+
+ #[test]
+ fn test_part1() {
+ assert_eq!(0, run_part1(TEXT_INPUT).unwrap());
+ }
+
+ #[test]
+ fn test_part2() {
+ assert_eq!(0, run_part2(TEXT_INPUT).unwrap());
+ }
+}