Implement day 4.

Nice code-reuse between 1 and 2. I'm not accustomed to this.
This commit is contained in:
2018-12-04 13:41:45 +01:00
parent 9a0f24d6bb
commit 1e51012d5e
3 changed files with 156 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
extern crate clap;
extern crate chrono;
extern crate regex;
use clap::{Arg, App};
use std::fs;
@@ -8,12 +9,14 @@ pub mod common;
pub mod day01;
pub mod day02;
pub mod day03;
pub mod day04;
fn get_impl(day: &str) -> Box<common::Solution> {
match day.parse() {
Ok(1) => Box::new(day01::Day01::new()),
Ok(2) => Box::new(day02::Day02::new()),
Ok(3) => Box::new(day03::Day03::new()),
Ok(4) => Box::new(day04::Day04::new()),
Ok(val) => panic!("Unimplemented day {}", val),
_ => panic!("Invalid number"),
}
@@ -59,7 +62,7 @@ mod tests {
#[test]
fn test_get_impl() {
// Verify that we can load all days
let last_implemented = 2;
let last_implemented = 4;
for d in 1..=last_implemented {
get_impl(&format!("{}", d));
}