mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-26 21:30:31 +01:00
Implement day 4.
Nice code-reuse between 1 and 2. I'm not accustomed to this.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user