2024-07-05 10:14:11 +00:00
|
|
|
mod solutions;
|
|
|
|
mod utils;
|
|
|
|
|
|
|
|
use std::{error::Error, time::SystemTime};
|
|
|
|
|
|
|
|
use solutions::*;
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<(), Box<dyn Error>> {
|
2024-07-05 11:59:00 +00:00
|
|
|
let problems: Vec<Box<dyn Solution + Sync>> = vec![
|
|
|
|
Box::new(xx::XX {}),
|
|
|
|
Box::new(valid_parentheses::ValidParentheses {})
|
|
|
|
];
|
2024-07-05 10:14:11 +00:00
|
|
|
|
|
|
|
let mut t = vec![];
|
|
|
|
|
|
|
|
// Run through and generate solutions
|
|
|
|
for problem in problems.leak() {
|
|
|
|
let task = tokio::spawn(async { problem.run().unwrap() });
|
|
|
|
t.push(task);
|
|
|
|
}
|
|
|
|
|
|
|
|
let start_time = SystemTime::now();
|
|
|
|
|
|
|
|
let mut problems = vec![];
|
|
|
|
for thread in t {
|
|
|
|
problems.push(thread.await?);
|
|
|
|
}
|
|
|
|
|
|
|
|
for problem in problems {
|
|
|
|
println!("========= Problem {} ==========", problem.id);
|
|
|
|
println!("Test1 Result: {}", problem.test1);
|
|
|
|
println!("Test2 Result: {}", problem.test2);
|
|
|
|
println!("Test3 Result: {}", problem.test3);
|
|
|
|
println!("========= {}ms =========\n", problem.time.as_millis());
|
|
|
|
}
|
|
|
|
|
|
|
|
println!(
|
|
|
|
"Ran LeetCode in {}ms",
|
|
|
|
SystemTime::now().duration_since(start_time)?.as_millis()
|
|
|
|
);
|
|
|
|
Ok(())
|
|
|
|
}
|