Added day 4.. early I know! And i fixed unit tests not compiling
This commit is contained in:
parent
554319e068
commit
0e225f4b04
0
src/input/day04
Normal file
0
src/input/day04
Normal file
0
src/input/day04_test1
Normal file
0
src/input/day04_test1
Normal file
0
src/input/day04_test2
Normal file
0
src/input/day04_test2
Normal file
@ -10,6 +10,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
Box::new(day01::Day01 {}),
|
Box::new(day01::Day01 {}),
|
||||||
Box::new(day02::Day02 {}),
|
Box::new(day02::Day02 {}),
|
||||||
Box::new(day03::Day03 {}),
|
Box::new(day03::Day03 {}),
|
||||||
|
Box::new(day04::Day04 {}),
|
||||||
];
|
];
|
||||||
|
|
||||||
// Run through and generate solutions
|
// Run through and generate solutions
|
||||||
|
@ -109,7 +109,7 @@ mod test {
|
|||||||
//Complete the Challenge
|
//Complete the Challenge
|
||||||
let answer = challenge
|
let answer = challenge
|
||||||
.part1(
|
.part1(
|
||||||
get_input(challenge.get_day(), utils::InputType::Test1)
|
utils::get_input(challenge.get_day(), utils::InputType::Test1)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_mut(),
|
.as_mut(),
|
||||||
)
|
)
|
||||||
@ -126,7 +126,7 @@ mod test {
|
|||||||
//Complete the Challenge
|
//Complete the Challenge
|
||||||
let answer = challenge
|
let answer = challenge
|
||||||
.part2(
|
.part2(
|
||||||
get_input(challenge.get_day(), utils::InputType::Test2)
|
utils::get_input(challenge.get_day(), utils::InputType::Test2)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_mut(),
|
.as_mut(),
|
||||||
)
|
)
|
||||||
|
@ -115,7 +115,7 @@ mod test {
|
|||||||
//Complete the Challenge
|
//Complete the Challenge
|
||||||
let answer = challenge
|
let answer = challenge
|
||||||
.part1(
|
.part1(
|
||||||
get_input(challenge.get_day(), utils::InputType::Test1)
|
utils::get_input(challenge.get_day(), utils::InputType::Test1)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_mut(),
|
.as_mut(),
|
||||||
)
|
)
|
||||||
@ -132,7 +132,7 @@ mod test {
|
|||||||
//Complete the Challenge
|
//Complete the Challenge
|
||||||
let answer = challenge
|
let answer = challenge
|
||||||
.part2(
|
.part2(
|
||||||
get_input(challenge.get_day(), utils::InputType::Test2)
|
utils::get_input(challenge.get_day(), utils::InputType::Test2)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_mut(),
|
.as_mut(),
|
||||||
)
|
)
|
||||||
|
@ -5,14 +5,14 @@ pub struct Day03 {}
|
|||||||
impl Solution for Day03 {
|
impl Solution for Day03 {
|
||||||
fn part1(
|
fn part1(
|
||||||
&self,
|
&self,
|
||||||
input: &mut Vec<String>,
|
_input: &mut Vec<String>,
|
||||||
) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
|
) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
|
||||||
Ok(Box::new("Ready"))
|
Ok(Box::new("Ready"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn part2(
|
fn part2(
|
||||||
&self,
|
&self,
|
||||||
input: &mut Vec<String>,
|
_input: &mut Vec<String>,
|
||||||
) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
|
) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
|
||||||
Ok(Box::new("Ready"))
|
Ok(Box::new("Ready"))
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ mod test {
|
|||||||
//Complete the Challenge
|
//Complete the Challenge
|
||||||
let answer = challenge
|
let answer = challenge
|
||||||
.part1(
|
.part1(
|
||||||
get_input(challenge.get_day(), utils::InputType::Test1)
|
utils::get_input(challenge.get_day(), utils::InputType::Test1)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_mut(),
|
.as_mut(),
|
||||||
)
|
)
|
||||||
@ -54,7 +54,7 @@ mod test {
|
|||||||
//Complete the Challenge
|
//Complete the Challenge
|
||||||
let answer = challenge
|
let answer = challenge
|
||||||
.part2(
|
.part2(
|
||||||
get_input(challenge.get_day(), utils::InputType::Test2)
|
utils::get_input(challenge.get_day(), utils::InputType::Test2)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_mut(),
|
.as_mut(),
|
||||||
)
|
)
|
||||||
|
66
src/solutions/day04.rs
Normal file
66
src/solutions/day04.rs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
use super::Solution;
|
||||||
|
|
||||||
|
pub struct Day04 {}
|
||||||
|
|
||||||
|
impl Solution for Day04 {
|
||||||
|
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 {
|
||||||
|
4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Day04 {}
|
||||||
|
|
||||||
|
/// Test from puzzle input
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::*;
|
||||||
|
use crate::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn part1() {
|
||||||
|
let challenge = day04::Day04 {};
|
||||||
|
|
||||||
|
//Complete the Challenge
|
||||||
|
let answer = challenge
|
||||||
|
.part1(
|
||||||
|
utils::get_input(challenge.get_day(), utils::InputType::Test1)
|
||||||
|
.unwrap()
|
||||||
|
.as_mut(),
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
assert_eq!(answer, "Ready");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn part2() {
|
||||||
|
let challenge = day04::Day04 {};
|
||||||
|
|
||||||
|
//Complete the Challenge
|
||||||
|
let answer = challenge
|
||||||
|
.part2(
|
||||||
|
utils::get_input(challenge.get_day(), utils::InputType::Test2)
|
||||||
|
.unwrap()
|
||||||
|
.as_mut(),
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
assert_eq!(answer, "Ready");
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
pub mod day01;
|
pub mod day01;
|
||||||
pub mod day02;
|
pub mod day02;
|
||||||
pub mod day03;
|
pub mod day03;
|
||||||
|
pub mod day04;
|
||||||
|
|
||||||
use crate::utils::{self, get_input};
|
use crate::utils::{self, get_input};
|
||||||
use std::{error::Error, fmt::Display, time::SystemTime};
|
use std::{error::Error, fmt::Display, time::SystemTime};
|
||||||
|
Loading…
Reference in New Issue
Block a user