Created tool to quickly spin up new puzzles
This commit is contained in:
@ -8,8 +8,8 @@ use solutions::*;
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn Error>> {
|
||||
let problems: Vec<Box<dyn Solution + Sync>> = vec![
|
||||
Box::new(valid_parentheses::ValidParentheses {}),
|
||||
Box::new(xx::XX {}),
|
||||
Box::new(valid_parentheses::ValidParentheses {})
|
||||
];
|
||||
|
||||
let mut t = vec![];
|
||||
|
@ -9,7 +9,7 @@ pub trait Solution {
|
||||
fn solution(&self, input: &mut Vec<String>) -> Result<Box<dyn Display + Sync>, Box<dyn Error>>;
|
||||
|
||||
// Get the id of the problem in question
|
||||
fn get_id(&self) -> u8;
|
||||
fn get_id(&self) -> u32;
|
||||
|
||||
fn run(&self) -> Result<Run, Box<dyn std::error::Error>> {
|
||||
let start_time = SystemTime::now();
|
||||
@ -29,7 +29,7 @@ pub struct Run {
|
||||
pub test1: Box<dyn Display + Sync>,
|
||||
pub test2: Box<dyn Display + Sync>,
|
||||
pub test3: Box<dyn Display + Sync>,
|
||||
pub id: u8,
|
||||
pub id: u32,
|
||||
pub time: core::time::Duration,
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ impl Solution for ValidParentheses {
|
||||
Ok(Box::new(stack.len() == 0))
|
||||
}
|
||||
|
||||
fn get_id(&self) -> u8 {
|
||||
fn get_id(&self) -> u32 {
|
||||
20
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ impl Solution for XX {
|
||||
&self,
|
||||
_input: &mut Vec<String>,
|
||||
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> {
|
||||
Ok(Box::new("Ready"))
|
||||
Ok(Box::new("Incomplete"))
|
||||
}
|
||||
|
||||
fn get_id(&self) -> u8 {
|
||||
fn get_id(&self) -> u32 {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ pub enum InputType {
|
||||
}
|
||||
|
||||
/// Function to get the input for a given leetcode problem
|
||||
pub fn get_input(id: u8, input: InputType) -> Result<Vec<String>, Box<dyn Error>> {
|
||||
pub fn get_input(id: u32, input: InputType) -> Result<Vec<String>, Box<dyn Error>> {
|
||||
// Find Input File Name
|
||||
let file_name = match input {
|
||||
InputType::Test1 => format!("src/input/{}_test1", id),
|
||||
|
Reference in New Issue
Block a user