Created Wireframe for code structure
This commit is contained in:
parent
8f24f18d26
commit
af0b387339
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"rust-analyzer.linkedProjects": [
|
||||
".\\Cargo.toml"
|
||||
]
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "AdventOfCode2023"
|
||||
name = "advent_of_code_2023"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
mod utils;
|
||||
|
||||
mod solutions;
|
||||
|
||||
fn main() {}
|
||||
|
7
src/solutions/dayxx.rs
Normal file
7
src/solutions/dayxx.rs
Normal file
@ -0,0 +1,7 @@
|
||||
use std::{error::Error, fmt::Display};
|
||||
|
||||
pub trait Solution {
|
||||
fn part1(&self, input: &mut Vec<String>) -> Result<Box<dyn Display>, Box<dyn Error>>;
|
||||
fn part2(&self, input: &mut Vec<String>) -> Result<Box<dyn Display>, Box<dyn Error>>;
|
||||
fn get_day(&self) -> u8;
|
||||
}
|
3
src/solutions/mod.rs
Normal file
3
src/solutions/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub mod dayxx;
|
||||
|
||||
pub mod day01;
|
32
src/utils.rs
Normal file
32
src/utils.rs
Normal file
@ -0,0 +1,32 @@
|
||||
use std::{
|
||||
error::Error,
|
||||
fs::File,
|
||||
io::{prelude::*, BufReader},
|
||||
};
|
||||
|
||||
/// Enum used to specify input
|
||||
pub enum InputType {
|
||||
Test,
|
||||
Actual,
|
||||
}
|
||||
|
||||
/// Function to get the input for a given day of AoC
|
||||
pub fn get_input(day: u8, input: InputType) -> Result<Vec<String>, Box<dyn Error>> {
|
||||
// Find Input File Name
|
||||
let file_name = match input {
|
||||
InputType::Test => format!("src/input/day{:02}_test.txt", day),
|
||||
InputType::Actual => format!("src/input/day{:02}.txt", day),
|
||||
};
|
||||
|
||||
// Read file into buffer
|
||||
let file = File::open(file_name)?;
|
||||
let reader = BufReader::new(file);
|
||||
|
||||
// Convert itterate buffer and return string vec
|
||||
let data = reader
|
||||
.lines()
|
||||
.map(|s| s.unwrap_or(String::from("")))
|
||||
.collect();
|
||||
|
||||
Ok(data)
|
||||
}
|
Loading…
Reference in New Issue
Block a user