Implement day 1 2018.

We've started.
This commit is contained in:
2018-12-01 11:03:48 +01:00
parent c41099d9d5
commit 3bbe6a479a
5 changed files with 1113 additions and 33 deletions

View File

@@ -4,14 +4,13 @@ use std::fs;
use std::io;
pub mod common;
pub mod day1;
pub mod day01;
fn get_impl(day: i32) -> Box<common::Solution> {
match day {
1 => { Box::new(day1::Day1::new()) }
_ => {
panic!("Unimplemented day {}", day)
}
fn get_impl(day: &str) -> Box<common::Solution> {
match day.parse() {
Ok(1) => { Box::new(day01::Day01::new()) }
Ok(val) => panic!("Unimplemented day {}", val),
_ => panic!("Invalid number"),
}
}
@@ -35,9 +34,7 @@ fn main() {
.takes_value(true))
.get_matches();
let day: i32 = (&matches.value_of("day").unwrap()).parse()
.expect("Invalid int");
let mut implementation = get_impl(day);
let mut implementation = get_impl(matches.value_of("day").unwrap());
let mut data: Box<io::Read> = match matches.value_of("input") {
Some(filename) => { Box::new(fs::File::open(filename).unwrap()) }
None => { Box::new(io::stdin()) }
@@ -59,7 +56,7 @@ mod tests {
// Verify that we can load all days
let last_implemented = 1;
for d in 1..(last_implemented + 1) {
get_impl(d);
get_impl(&format!("{}", d));
}
}
}