Added day 7

This commit is contained in:
Luke Else 2023-12-05 23:00:18 +00:00
parent 43e3a8ac35
commit 7057d3006b
7 changed files with 87 additions and 0 deletions

19
scripts/new.py Normal file
View File

@ -0,0 +1,19 @@
def create_and_populate_file(file_name, content):
try:
with open(file_name, 'w') as file:
file.write(content)
print(f"File {file_name} created and populated successfully.")
except Exception as e:
print(f"Error: {e}")
def main():
# Define the file names and template content
file_names = ["file1.txt", "file2.txt", "file3.txt"]
template_content = "This is a template file.\nYou can replace this content."
# Create and populate each file
for file_name in file_names:
create_and_populate_file(file_name, template_content)
if __name__ == "__main__":
main()

0
src/input/day07 Normal file
View File

0
src/input/day07_test1 Normal file
View File

0
src/input/day07_test2 Normal file
View File

View File

@ -14,6 +14,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
Box::new(day04::Day04 {}), Box::new(day04::Day04 {}),
Box::new(day05::Day05 {}), Box::new(day05::Day05 {}),
Box::new(day06::Day06 {}), Box::new(day06::Day06 {}),
Box::new(day07::Day07 {}),
]; ];
let mut t = vec![]; let mut t = vec![];

66
src/solutions/day07.rs Normal file
View File

@ -0,0 +1,66 @@
use super::Solution;
pub struct Day07 {}
impl Solution for Day07 {
fn part1(
&self,
_input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready"))
}
fn part2(
&self,
_input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready"))
}
fn get_day(&self) -> u8 {
7
}
}
impl Day07 {}
/// Test from puzzle input
#[cfg(test)]
mod test {
use super::*;
use crate::*;
#[test]
fn part1() {
let challenge = day07::Day07 {};
//Complete the Challenge
let answer = challenge
.part1(
utils::get_input(challenge.get_day(), utils::InputType::Test1)
.unwrap()
.as_mut(),
)
.unwrap()
.to_string();
assert_eq!(answer, "Ready");
}
#[test]
fn part2() {
let challenge = day07::Day07 {};
//Complete the Challenge
let answer = challenge
.part2(
utils::get_input(challenge.get_day(), utils::InputType::Test2)
.unwrap()
.as_mut(),
)
.unwrap()
.to_string();
assert_eq!(answer, "Ready");
}
}

View File

@ -4,6 +4,7 @@ pub mod day03;
pub mod day04; pub mod day04;
pub mod day05; pub mod day05;
pub mod day06; pub mod day06;
pub mod day07;
use crate::utils::{self, get_input}; use crate::utils::{self, get_input};
use std::{error::Error, fmt::Display, time::SystemTime}; use std::{error::Error, fmt::Display, time::SystemTime};