Change Solution trait
This commit is contained in:
parent
793241a355
commit
100fd47491
|
@ -1,4 +1,5 @@
|
||||||
pub trait Solution {
|
pub trait Solution {
|
||||||
fn part_one(&self) -> String;
|
fn part_one(&self) -> String;
|
||||||
fn part_two(&self) -> String;
|
fn part_two(&self) -> String;
|
||||||
|
fn input_path(&self) -> &'static str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,14 @@ pub mod part_two;
|
||||||
|
|
||||||
use crate::utils::solution::Solution;
|
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 {
|
fn part_one(&self) -> String {
|
||||||
// Implementation for part one of day 1
|
// Implementation for part one of day 1
|
||||||
// ...
|
// ...
|
||||||
|
|
|
@ -3,9 +3,14 @@ pub mod part_two;
|
||||||
|
|
||||||
use crate::utils::solution::Solution;
|
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 {
|
fn part_one(&self) -> String {
|
||||||
// Implementation for part one of day 1
|
// Implementation for part one of day 1
|
||||||
// ...
|
// ...
|
||||||
|
|
|
@ -2,9 +2,14 @@ pub mod part_one;
|
||||||
|
|
||||||
use crate::utils::solution::Solution;
|
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 {
|
fn part_one(&self) -> String {
|
||||||
// Implementation for part one of day 1
|
// Implementation for part one of day 1
|
||||||
// ...
|
// ...
|
||||||
|
|
|
@ -2,9 +2,14 @@ pub mod part_one;
|
||||||
|
|
||||||
use crate::utils::solution::Solution;
|
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 {
|
fn part_one(&self) -> String {
|
||||||
// Implementation for part one of day 1
|
// Implementation for part one of day 1
|
||||||
// ...
|
// ...
|
||||||
|
|
|
@ -3,9 +3,14 @@ pub mod part_two;
|
||||||
|
|
||||||
use crate::utils::solution::Solution;
|
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 {
|
fn part_one(&self) -> String {
|
||||||
// Implementation for part one of day 1
|
// Implementation for part one of day 1
|
||||||
// ...
|
// ...
|
||||||
|
|
|
@ -4,9 +4,14 @@ pub mod part_two;
|
||||||
|
|
||||||
use crate::utils::solution::Solution;
|
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 {
|
fn part_one(&self) -> String {
|
||||||
// Implementation for part one of day 1
|
// Implementation for part one of day 1
|
||||||
// ...
|
// ...
|
||||||
|
|
|
@ -6,15 +6,19 @@ use crate::utils::solution::Solution;
|
||||||
use crate::utils::input_reader;
|
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 {
|
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 {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,16 +7,18 @@ pub mod day_04_scratchcards;
|
||||||
pub mod day_06_wait_for_it;
|
pub mod day_06_wait_for_it;
|
||||||
pub mod day_08_haunted_wasteland;
|
pub mod day_08_haunted_wasteland;
|
||||||
pub mod day_09_mirage_maintenance;
|
pub mod day_09_mirage_maintenance;
|
||||||
|
pub mod day_10_pipe_maze;
|
||||||
|
|
||||||
pub fn run(day: &str) {
|
pub fn run(day: &str) {
|
||||||
let solution: Box<dyn Solution> = match day {
|
let solution: Box<dyn Solution> = match day {
|
||||||
"1" => Box::new(day_01_trebuchet::Day1Solution),
|
"1" => Box::new(day_01_trebuchet::DaySolution),
|
||||||
"2" => Box::new(day_02_cube_conundrum::Day2Solution),
|
"2" => Box::new(day_02_cube_conundrum::DaySolution),
|
||||||
"3" => Box::new(day_03_gear_ratios::Day3Solution),
|
"3" => Box::new(day_03_gear_ratios::DaySolution),
|
||||||
"4" => Box::new(day_04_scratchcards::Day4Solution),
|
"4" => Box::new(day_04_scratchcards::DaySolution),
|
||||||
"6" => Box::new(day_06_wait_for_it::Day6Solution),
|
"6" => Box::new(day_06_wait_for_it::DaySolution),
|
||||||
"8" => Box::new(day_08_haunted_wasteland::Day8Solution),
|
"8" => Box::new(day_08_haunted_wasteland::DaySolution),
|
||||||
"9" => Box::new(day_09_mirage_maintenance::Day9Solution),
|
"9" => Box::new(day_09_mirage_maintenance::DaySolution),
|
||||||
|
"10" => Box::new(day_10_pipe_maze::DaySolution),
|
||||||
_ => panic!("Invalid day specified"),
|
_ => panic!("Invalid day specified"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue