Cleaned up runner to use 2 test inputs and prepared for day 2
This commit is contained in:
parent
b08290c70c
commit
3ff45cae13
7
src/input/day01_test2
Normal file
7
src/input/day01_test2
Normal file
@ -0,0 +1,7 @@
|
||||
two1nine
|
||||
eightwothree
|
||||
abcone2threexyz
|
||||
xtwone3four
|
||||
4nineeightseven2
|
||||
zoneight234
|
||||
7pqrstsixteen
|
0
src/input/day02
Normal file
0
src/input/day02
Normal file
0
src/input/day02_test1
Normal file
0
src/input/day02_test1
Normal file
0
src/input/day02_test2
Normal file
0
src/input/day02_test2
Normal file
23
src/main.rs
23
src/main.rs
@ -3,21 +3,24 @@ mod solutions;
|
||||
|
||||
use std::error::Error;
|
||||
|
||||
use solutions::{
|
||||
dayxx::Solution,
|
||||
day01
|
||||
};
|
||||
use solutions::{dayxx::Solution, *};
|
||||
|
||||
use crate::utils::get_input;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>>{
|
||||
// Day 1
|
||||
let day01 = day01::Day01{};
|
||||
println!("Day01 Part1 Test: {}", day01.part1(get_input(day01.get_day(), utils::InputType::Test)?.as_mut())?);
|
||||
println!("Day01 Part1 Result: {}", day01.part1(get_input(day01.get_day(), utils::InputType::Actual)?.as_mut())?);
|
||||
|
||||
println!("Day01 Part2 Test: {}", day01.part2(get_input(day01.get_day(), utils::InputType::Test)?.as_mut())?);
|
||||
println!("Day01 Part2 Result: {}", day01.part2(get_input(day01.get_day(), utils::InputType::Actual)?.as_mut())?);
|
||||
let days: Vec<Box<dyn Solution>> = vec![
|
||||
Box::new(day01::Day01{}),
|
||||
Box::new(day02::Day02{})
|
||||
];
|
||||
|
||||
for day in days {
|
||||
println!("Day{} Part1 Test: {}", day.get_day(), day.part1(get_input(day.get_day(), utils::InputType::Test1)?.as_mut())?);
|
||||
println!("Day{} Part1 Result: {}", day.get_day(), day.part1(get_input(day.get_day(), utils::InputType::Actual)?.as_mut())?);
|
||||
|
||||
println!("Day{} Part2 Test: {}", day.get_day(), day.part2(get_input(day.get_day(), utils::InputType::Test2)?.as_mut())?);
|
||||
println!("Day{} Part2 Result: {}", day.get_day(), day.part2(get_input(day.get_day(), utils::InputType::Actual)?.as_mut())?);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
27
src/solutions/day02.rs
Normal file
27
src/solutions/day02.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use super::dayxx::Solution;
|
||||
|
||||
pub struct Day02 {}
|
||||
|
||||
impl Solution for Day02 {
|
||||
fn part1(
|
||||
&self,
|
||||
input: &mut Vec<String>,
|
||||
) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
|
||||
Ok(Box::new("Ready"))
|
||||
}
|
||||
|
||||
fn part2(
|
||||
&self,
|
||||
input: &mut Vec<String>,
|
||||
) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
|
||||
Ok(Box::new("Ready"))
|
||||
}
|
||||
|
||||
fn get_day(&self) -> u8 {
|
||||
2
|
||||
}
|
||||
}
|
||||
|
||||
impl Day02 {
|
||||
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
pub mod dayxx;
|
||||
|
||||
pub mod day01;
|
||||
pub mod day02;
|
||||
|
@ -6,7 +6,8 @@ use std::{
|
||||
|
||||
/// Enum used to specify input
|
||||
pub enum InputType {
|
||||
Test,
|
||||
Test1,
|
||||
Test2,
|
||||
Actual,
|
||||
}
|
||||
|
||||
@ -14,7 +15,8 @@ pub enum InputType {
|
||||
pub fn get_input(day: u8, input: InputType) -> Result<Vec<String>, Box<dyn Error>> {
|
||||
// Find Input File Name
|
||||
let file_name = match input {
|
||||
InputType::Test => format!("src/input/day{:02}_test", day),
|
||||
InputType::Test1 => format!("src/input/day{:02}_test1", day),
|
||||
InputType::Test2 => format!("src/input/day{:02}_test2", day),
|
||||
InputType::Actual => format!("src/input/day{:02}", day),
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user