diff --git a/src/utils/solution.rs b/src/utils/solution.rs index 7bd1d8c..2813512 100644 --- a/src/utils/solution.rs +++ b/src/utils/solution.rs @@ -1,4 +1,5 @@ pub trait Solution { fn part_one(&self) -> String; fn part_two(&self) -> String; + fn input_path(&self) -> &'static str; } diff --git a/src/year_2023/day_01_trebuchet/mod.rs b/src/year_2023/day_01_trebuchet/mod.rs index a69fd56..36e88d6 100644 --- a/src/year_2023/day_01_trebuchet/mod.rs +++ b/src/year_2023/day_01_trebuchet/mod.rs @@ -3,9 +3,14 @@ pub mod part_two; use crate::utils::solution::Solution; -pub struct Day1Solution; +pub struct DaySolution; + +impl Solution for DaySolution { + + fn input_path(&self) -> &'static str { + "Not implemented" + } -impl Solution for Day1Solution { fn part_one(&self) -> String { // Implementation for part one of day 1 // ... diff --git a/src/year_2023/day_02_cube_conundrum/mod.rs b/src/year_2023/day_02_cube_conundrum/mod.rs index 42eb2af..36e88d6 100644 --- a/src/year_2023/day_02_cube_conundrum/mod.rs +++ b/src/year_2023/day_02_cube_conundrum/mod.rs @@ -3,9 +3,14 @@ pub mod part_two; use crate::utils::solution::Solution; -pub struct Day2Solution; +pub struct DaySolution; + +impl Solution for DaySolution { + + fn input_path(&self) -> &'static str { + "Not implemented" + } -impl Solution for Day2Solution { fn part_one(&self) -> String { // Implementation for part one of day 1 // ... diff --git a/src/year_2023/day_03_gear_ratios/mod.rs b/src/year_2023/day_03_gear_ratios/mod.rs index 8734eb2..d75161a 100644 --- a/src/year_2023/day_03_gear_ratios/mod.rs +++ b/src/year_2023/day_03_gear_ratios/mod.rs @@ -2,9 +2,14 @@ pub mod part_one; use crate::utils::solution::Solution; -pub struct Day3Solution; +pub struct DaySolution; + +impl Solution for DaySolution { + + fn input_path(&self) -> &'static str { + "Not implemented" + } -impl Solution for Day3Solution { fn part_one(&self) -> String { // Implementation for part one of day 1 // ... diff --git a/src/year_2023/day_04_scratchcards/mod.rs b/src/year_2023/day_04_scratchcards/mod.rs index 45cd080..d75161a 100644 --- a/src/year_2023/day_04_scratchcards/mod.rs +++ b/src/year_2023/day_04_scratchcards/mod.rs @@ -2,9 +2,14 @@ pub mod part_one; use crate::utils::solution::Solution; -pub struct Day4Solution; +pub struct DaySolution; + +impl Solution for DaySolution { + + fn input_path(&self) -> &'static str { + "Not implemented" + } -impl Solution for Day4Solution { fn part_one(&self) -> String { // Implementation for part one of day 1 // ... diff --git a/src/year_2023/day_06_wait_for_it/mod.rs b/src/year_2023/day_06_wait_for_it/mod.rs index 8e7753a..36e88d6 100644 --- a/src/year_2023/day_06_wait_for_it/mod.rs +++ b/src/year_2023/day_06_wait_for_it/mod.rs @@ -3,9 +3,14 @@ pub mod part_two; use crate::utils::solution::Solution; -pub struct Day6Solution; +pub struct DaySolution; + +impl Solution for DaySolution { + + fn input_path(&self) -> &'static str { + "Not implemented" + } -impl Solution for Day6Solution { fn part_one(&self) -> String { // Implementation for part one of day 1 // ... diff --git a/src/year_2023/day_08_haunted_wasteland/mod.rs b/src/year_2023/day_08_haunted_wasteland/mod.rs index fbd7cb6..cb82532 100644 --- a/src/year_2023/day_08_haunted_wasteland/mod.rs +++ b/src/year_2023/day_08_haunted_wasteland/mod.rs @@ -4,9 +4,14 @@ pub mod part_two; use crate::utils::solution::Solution; -pub struct Day8Solution; +pub struct DaySolution; + +impl Solution for DaySolution { + + fn input_path(&self) -> &'static str { + "Not implemented" + } -impl Solution for Day8Solution { fn part_one(&self) -> String { // Implementation for part one of day 1 // ... diff --git a/src/year_2023/day_09_mirage_maintenance/mod.rs b/src/year_2023/day_09_mirage_maintenance/mod.rs index 49f0c19..b96f803 100644 --- a/src/year_2023/day_09_mirage_maintenance/mod.rs +++ b/src/year_2023/day_09_mirage_maintenance/mod.rs @@ -6,15 +6,19 @@ use crate::utils::solution::Solution; use crate::utils::input_reader; -pub struct Day9Solution; +pub struct DaySolution; -impl Solution for Day9Solution { +impl Solution for DaySolution { + + fn input_path(&self) -> &'static str { + "input/2023/day_09/input.txt" + } fn part_one(&self) -> String { - input_reader::read_input_file("input/2023/day_09/input.txt", part_one::part_one) + input_reader::read_input_file(self.input_path(), part_one::part_one) } fn part_two(&self) -> String { - input_reader::read_input_file("input/2023/day_09/input.txt", part_two::part_two) + input_reader::read_input_file(self.input_path(), part_two::part_two) } } diff --git a/src/year_2023/mod.rs b/src/year_2023/mod.rs index 04d683d..7cfc9b1 100644 --- a/src/year_2023/mod.rs +++ b/src/year_2023/mod.rs @@ -7,16 +7,18 @@ pub mod day_04_scratchcards; pub mod day_06_wait_for_it; pub mod day_08_haunted_wasteland; pub mod day_09_mirage_maintenance; +pub mod day_10_pipe_maze; pub fn run(day: &str) { let solution: Box = match day { - "1" => Box::new(day_01_trebuchet::Day1Solution), - "2" => Box::new(day_02_cube_conundrum::Day2Solution), - "3" => Box::new(day_03_gear_ratios::Day3Solution), - "4" => Box::new(day_04_scratchcards::Day4Solution), - "6" => Box::new(day_06_wait_for_it::Day6Solution), - "8" => Box::new(day_08_haunted_wasteland::Day8Solution), - "9" => Box::new(day_09_mirage_maintenance::Day9Solution), + "1" => Box::new(day_01_trebuchet::DaySolution), + "2" => Box::new(day_02_cube_conundrum::DaySolution), + "3" => Box::new(day_03_gear_ratios::DaySolution), + "4" => Box::new(day_04_scratchcards::DaySolution), + "6" => Box::new(day_06_wait_for_it::DaySolution), + "8" => Box::new(day_08_haunted_wasteland::DaySolution), + "9" => Box::new(day_09_mirage_maintenance::DaySolution), + "10" => Box::new(day_10_pipe_maze::DaySolution), _ => panic!("Invalid day specified"), };