From 7057d3006b2f09405b4d07307325a6a701361cb1 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Tue, 5 Dec 2023 23:00:18 +0000 Subject: [PATCH] Added day 7 --- scripts/new.py | 19 ++++++++++++ src/input/day07 | 0 src/input/day07_test1 | 0 src/input/day07_test2 | 0 src/main.rs | 1 + src/solutions/day07.rs | 66 ++++++++++++++++++++++++++++++++++++++++++ src/solutions/mod.rs | 1 + 7 files changed, 87 insertions(+) create mode 100644 scripts/new.py create mode 100644 src/input/day07 create mode 100644 src/input/day07_test1 create mode 100644 src/input/day07_test2 create mode 100644 src/solutions/day07.rs diff --git a/scripts/new.py b/scripts/new.py new file mode 100644 index 0000000..6f5fd3b --- /dev/null +++ b/scripts/new.py @@ -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() \ No newline at end of file diff --git a/src/input/day07 b/src/input/day07 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day07_test1 b/src/input/day07_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day07_test2 b/src/input/day07_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/main.rs b/src/main.rs index 3f4680a..2566ac4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,7 @@ async fn main() -> Result<(), Box> { Box::new(day04::Day04 {}), Box::new(day05::Day05 {}), Box::new(day06::Day06 {}), + Box::new(day07::Day07 {}), ]; let mut t = vec![]; diff --git a/src/solutions/day07.rs b/src/solutions/day07.rs new file mode 100644 index 0000000..193959b --- /dev/null +++ b/src/solutions/day07.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day07 {} + +impl Solution for Day07 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + 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"); + } +} diff --git a/src/solutions/mod.rs b/src/solutions/mod.rs index 1850896..31b31d6 100644 --- a/src/solutions/mod.rs +++ b/src/solutions/mod.rs @@ -4,6 +4,7 @@ pub mod day03; pub mod day04; pub mod day05; pub mod day06; +pub mod day07; use crate::utils::{self, get_input}; use std::{error::Error, fmt::Display, time::SystemTime};