Advent of Code 2019
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.1 KiB

3 years ago
#[macro_use]
extern crate clap;
use clap::{Arg, App};
use std::fs::File;
use std::io::BufReader;
mod day1;
fn main() {
let matches = App::new("Advent of Code 2019")
.version("0.1")
.arg(Arg::with_name("challenge")
.short("c")
.long("challenge")
.value_name("CHALLENGE")
.required(true)
.takes_value(true)
.min_values(1)
.max_values(50))
.arg(Arg::with_name("input")
.short("i")
.long("input")
.value_name("INPUT")
.required(true)
.takes_value(true))
.get_matches();
let input = matches.value_of("input").unwrap();
let challenge = value_t!(matches, "challenge", usize).unwrap() - 1;
let input_file = File::open(input).expect("Unable to open input file");
let reader = BufReader::new(input_file);
let challenges = [
day1::part1, day1::part2
];
if let Some(f) = challenges.get(challenge) {
f(reader);
} else {
println!("Challenge {}, part {} not unimplemented", challenge / 2 + 1, challenge % 2 +1)
}
}