2022-10-29 17:18:58 +02:00
|
|
|
/*
|
|
|
|
* This file contains template code.
|
2022-10-29 17:25:11 +02:00
|
|
|
* There is no need to edit this file unless you want to change template functionality.
|
2022-10-29 17:18:58 +02:00
|
|
|
*/
|
2022-11-29 20:17:00 +01:00
|
|
|
use advent_of_code::{ANSI_BOLD, ANSI_ITALIC, ANSI_RESET};
|
2021-12-29 14:36:48 +01:00
|
|
|
use std::process::Command;
|
2021-12-29 14:12:01 +01:00
|
|
|
|
|
|
|
fn main() {
|
2021-12-29 19:14:40 +01:00
|
|
|
let total: f64 = (1..=25)
|
|
|
|
.map(|day| {
|
2023-02-04 22:17:04 +00:00
|
|
|
let day = format!("{day:02}");
|
2021-12-29 14:36:48 +01:00
|
|
|
|
2022-12-04 11:56:41 +01:00
|
|
|
let mut args = vec!["run", "--bin", &day];
|
|
|
|
if cfg!(not(debug_assertions)) {
|
|
|
|
args.push("--release");
|
|
|
|
}
|
|
|
|
|
|
|
|
let cmd = Command::new("cargo").args(&args).output().unwrap();
|
2021-12-29 14:12:01 +01:00
|
|
|
|
2021-12-29 19:14:40 +01:00
|
|
|
println!("----------");
|
2023-02-04 22:17:04 +00:00
|
|
|
println!("{ANSI_BOLD}| Day {day} |{ANSI_RESET}");
|
2021-12-29 19:14:40 +01:00
|
|
|
println!("----------");
|
|
|
|
|
|
|
|
let output = String::from_utf8(cmd.stdout).unwrap();
|
|
|
|
let is_empty = output.is_empty();
|
|
|
|
|
2022-10-29 17:18:58 +02:00
|
|
|
println!(
|
|
|
|
"{}",
|
|
|
|
if is_empty {
|
|
|
|
"Not solved."
|
|
|
|
} else {
|
|
|
|
output.trim()
|
|
|
|
}
|
|
|
|
);
|
2021-12-29 19:14:40 +01:00
|
|
|
|
|
|
|
if is_empty {
|
|
|
|
0_f64
|
2021-12-29 14:36:48 +01:00
|
|
|
} else {
|
2022-11-29 20:17:00 +01:00
|
|
|
advent_of_code::parse_exec_time(&output)
|
2021-12-29 14:36:48 +01:00
|
|
|
}
|
2021-12-29 19:14:40 +01:00
|
|
|
})
|
|
|
|
.sum();
|
|
|
|
|
2023-02-04 22:17:04 +00:00
|
|
|
println!("{ANSI_BOLD}Total:{ANSI_RESET} {ANSI_ITALIC}{total:.2}ms{ANSI_RESET}");
|
2021-12-29 14:12:01 +01:00
|
|
|
}
|