aoc-2022/src/main.rs
2022-12-05 16:28:12 +00:00

42 lines
1.1 KiB
Rust

use chrono::prelude::*;
use std::path::Path;
use std::time::Instant;
mod day01;
mod day02;
mod day03;
mod day04;
mod day05;
mod day06;
fn main() {
let today = Local::now().day();
let now = Instant::now();
if cfg!(feature = "day01") || (cfg!(feature = "today") && today == 1) {
day01::run();
}
if cfg!(feature = "day02") || (cfg!(feature = "today") && today == 2) {
day02::run();
}
if cfg!(feature = "day03") || (cfg!(feature = "today") && today == 3) {
day03::run();
}
if cfg!(feature = "day04") || (cfg!(feature = "today") && today == 4) {
day04::run();
}
if cfg!(feature = "day05") || (cfg!(feature = "today") && today == 5) {
day05::run();
}
if cfg!(feature = "day06") || (cfg!(feature = "today") && today == 6) {
day06::run();
}
println!("Finished, time taken: {:?}", now.elapsed())
}
pub fn read(day: &str) -> String {
let fmt = format!("input/{}.txt", day);
let path = Path::new(&fmt);
println!("path: {:?}", path);
std::fs::read_to_string(path).unwrap()
}