From 2044e43b3475691a035ae8dca3e836ff96460425 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Sun, 25 Sep 2016 14:56:13 -0700 Subject: [PATCH] [rust] Allow for running previous days --- rust/src/main.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index 05febe4..30cf1af 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -1,3 +1,4 @@ +use std::env; use std::io::prelude::*; use std::io; @@ -5,7 +6,22 @@ extern crate advent_of_code; use advent_of_code::*; fn main() { - let mut input = String::new(); - io::stdin().read_to_string(&mut input).ok(); - println!("{}", day_10::solve(&input)); + let mut input = String::new(); + io::stdin().read_to_string(&mut input).ok(); + + let solution: String = + match env::args().nth(1).as_ref().map(String::as_ref) { + Some("1") => day_01::solve(&input).to_string(), + Some("2") => day_02::solve(&input).to_string(), + Some("3") => day_03::solve(&input).to_string(), + Some("4") => day_04::solve(&input).to_string(), + Some("5") => day_05::solve(&input).to_string(), + Some("6") => day_06::solve(&input).to_string(), + Some("7") => day_07::solve(&input, "a").to_string(), + Some("8") => day_08::solve(&input).to_string(), + Some("9") => day_09::solve(&input).to_string(), + _ => day_10::solve(&input), + }; + + println!("{}", solution); }