diff --git a/Cargo.lock b/Cargo.lock index e5f554f..4fe9fdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,6 +7,7 @@ name = "advent_of_code_2024" version = "0.1.0" dependencies = [ "day_1", + "day_2", "solver_base", "utils", ] @@ -19,6 +20,22 @@ dependencies = [ "utils", ] +[[package]] +name = "day_2" +version = "0.1.0" +dependencies = [ + "solver_base", + "utils", +] + +[[package]] +name = "day_3" +version = "0.1.0" +dependencies = [ + "solver_base", + "utils", +] + [[package]] name = "solver_base" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index bad3034..9a5f85c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,15 +5,24 @@ edition = "2021" [workspace] # resolver = "2" # Important! wgpu/Bevy needs this! .. so not important for this project? -members = ["crates/utils", "crates/solver_base", "crates/day_1"] +members = [ + "crates/utils", + "crates/solver_base", + "crates/day_1", + "crates/day_2", + "crates/day_3" + ] [dependencies] utils = { workspace = true } solver_base = { workspace = true } day_1 = { workspace = true } +day_2 = { workspace = true } [workspace.dependencies] utils = { path = "crates/utils" } solver_base = { path = "crates/solver_base" } -day_1 = { path = "crates/day_1" } \ No newline at end of file +day_1 = { path = "crates/day_1" } +day_2 = { path = "crates/day_2" } +day_3 = { path = "crates/day_3" } \ No newline at end of file diff --git a/crates/day_1/src/day_1.rs b/crates/day_1/src/day_1.rs index 10067cd..560a2cc 100644 --- a/crates/day_1/src/day_1.rs +++ b/crates/day_1/src/day_1.rs @@ -1,9 +1,19 @@ -use ::solver_base::solver_base::{Solver, RunMode}; +/****************************************************************************** +* @file day_1.rs +* @author Joey Pollack +* @date 2024/12/03 (y/m/d) +* @modified 2024/12/03 (y/m/d) +* @copyright Joseph R Pollack +* @brief Advent of Code 2024 day 1 problems +******************************************************************************/ + +use ::solver_base::solver_base::{Solver, DataSet, RunMode}; use utils::utils; pub struct Day1 { + data_set: DataSet, run_mode: RunMode, do_debug_prints: bool, data_a: Vec, @@ -19,7 +29,7 @@ impl Day1 { pub fn new() -> Day1 { - Day1 { run_mode: RunMode::FirstCaseTest, do_debug_prints: false, data_a: vec![], data_b: vec![], distances: vec![], final_result: 0 } + Day1 { data_set: DataSet::Test, run_mode: RunMode::FirstCase, do_debug_prints: false, data_a: vec![], data_b: vec![], distances: vec![], final_result: 0 } } fn solve_first_case(self: &mut Self) -> String @@ -93,19 +103,17 @@ impl Solver for Day1 println!("DATA: {}", data); } - fn init(self: &mut Self, run_mode: RunMode, enable_debug_prints: bool) + fn init(self: &mut Self, data_set: DataSet, run_mode: RunMode, enable_debug_prints: bool) { self.run_mode = run_mode; self.do_debug_prints = enable_debug_prints; let dir = utils::get_working_dir(); let data_filename = - match self.run_mode + match self.data_set { - RunMode::FirstCaseTest => format!("{}/data/test_input", dir), - RunMode::FirstCase => format!("{}/data/input", dir), - RunMode::SecondCaseTest => format!("{}/data/test_input", dir), - RunMode::SecondCase => format!("{}/data/input", dir), + DataSet::Test => format!("{}/data/test_input", dir), + DataSet::Full => format!("{}/data/input", dir), }; @@ -142,12 +150,12 @@ impl Solver for Day1 { match self.run_mode { - RunMode::FirstCase | RunMode::FirstCaseTest => + RunMode::FirstCase => { self.solve_first_case() }, - RunMode::SecondCase | RunMode::SecondCaseTest => + RunMode::SecondCase => { self.solve_second_case() } diff --git a/crates/day_2/Cargo.toml b/crates/day_2/Cargo.toml new file mode 100644 index 0000000..fb5a86e --- /dev/null +++ b/crates/day_2/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "day_2" +description = "Day 2 of the Advent of Code 2024" +version = "0.1.0" +edition = "2021" + +[dependencies] +solver_base = { workspace = true } +utils = { workspace = true } \ No newline at end of file diff --git a/crates/day_2/build.rs b/crates/day_2/build.rs new file mode 100644 index 0000000..4cd9495 --- /dev/null +++ b/crates/day_2/build.rs @@ -0,0 +1,33 @@ + +use std::{env, fs, path::Path}; + +fn main() +{ + // let out_dir = env::var("OUT_DIR").unwrap(); + // let cwd = env::var("CARGO_MANIFEST_DIR").unwrap(); + // println!("CWD: {}\n", cwd); + // let data_dir = cwd + "\\data"; + // let data_path = Path::new(&data_dir); + // println!("Data path: {}", data_path.to_string_lossy()); + + // let data_path = Path::new("data/test_input"); + + // let out_dir = env::var("OUT_DIR").unwrap(); + // panic!("out_dir: {}", out_dir); + let out_path = format!("../../target/{}", &env::var("PROFILE").unwrap()); + let out_path = Path::new(&out_path); + //let out_path = Path::new(&out_dir).join(&env::var("PROFILE").unwrap()); + let out_path_data = out_path.join(Path::new("data")); + + if !out_path_data.exists() + { + fs::create_dir(&out_path_data).expect(&format!("Could not create data directory at: {}", out_path_data.to_string_lossy())); + } + + for file in fs::read_dir("data").unwrap() + { + let file = file.unwrap(); + let dest = out_path.join(file.path()); + fs::copy(file.path(), &dest).expect(&format!("Could not copy file {} to {}", file.path().to_string_lossy(), dest.to_string_lossy())); + } +} \ No newline at end of file diff --git a/crates/day_2/data/input b/crates/day_2/data/input new file mode 100644 index 0000000..e68acf3 --- /dev/null +++ b/crates/day_2/data/input @@ -0,0 +1,1000 @@ +1 3 4 5 8 10 7 +48 51 54 55 55 +7 9 12 15 16 17 20 24 +49 52 55 57 58 60 65 +73 75 77 80 81 78 81 82 +83 84 87 85 86 84 +76 77 80 79 80 80 +25 27 28 29 28 30 34 +21 23 26 28 26 27 34 +71 72 72 73 74 75 77 80 +31 33 36 36 38 40 39 +11 14 17 17 17 +43 45 45 48 52 +54 57 58 59 61 62 62 68 +47 50 53 57 60 63 66 +46 47 48 52 53 52 +89 91 94 98 98 +56 59 62 64 66 70 74 +50 52 53 57 60 61 68 +72 74 75 78 84 86 89 90 +47 49 56 57 60 59 +63 64 67 69 70 75 77 77 +59 62 63 65 68 75 79 +75 77 79 85 92 +9 8 11 12 15 17 19 +32 30 32 35 32 +43 40 42 43 46 46 +7 5 8 11 12 13 16 20 +78 77 78 79 82 85 88 95 +76 74 75 72 75 77 78 80 +31 30 32 34 32 34 35 34 +16 14 13 16 17 19 21 21 +83 80 82 80 83 87 +48 45 48 51 50 53 59 +4 2 2 5 8 11 +58 55 57 60 60 59 +65 64 65 67 67 68 69 69 +24 21 22 24 24 25 29 +21 20 20 22 23 29 +48 46 48 50 51 52 56 59 +58 57 58 60 62 66 64 +71 70 74 77 80 80 +63 61 62 66 68 72 +49 48 50 53 54 58 63 +4 2 3 10 13 14 +56 54 57 58 64 61 +8 6 11 14 15 15 +24 23 26 31 33 37 +27 24 26 31 36 +80 80 82 85 88 89 +17 17 20 21 23 25 23 +46 46 49 52 55 56 58 58 +14 14 17 18 20 23 24 28 +11 11 14 17 20 23 29 +27 27 26 27 30 31 34 35 +81 81 84 82 85 82 +69 69 70 72 70 71 71 +30 30 29 32 36 +1 1 4 1 3 5 12 +71 71 72 73 76 77 77 79 +66 66 67 70 73 73 71 +83 83 85 86 86 86 +84 84 87 88 88 89 91 95 +27 27 30 30 33 36 43 +36 36 37 38 41 45 48 +85 85 87 91 89 +18 18 20 22 26 26 +57 57 60 64 68 +34 34 37 41 47 +76 76 83 84 86 89 90 92 +16 16 18 25 28 30 29 +43 43 48 49 50 50 +56 56 59 60 66 68 71 75 +25 25 27 32 35 42 +18 22 23 25 26 +67 71 73 74 75 76 78 77 +28 32 34 37 37 +77 81 82 84 87 90 91 95 +40 44 47 48 53 +88 92 90 92 93 96 +80 84 86 89 91 90 93 92 +63 67 66 67 70 70 +81 85 87 84 88 +61 65 62 64 65 70 +61 65 66 67 70 70 71 74 +34 38 38 39 42 43 41 +88 92 94 96 96 97 97 +6 10 10 13 14 15 17 21 +28 32 32 34 37 42 +5 9 13 16 19 22 +64 68 71 75 73 +7 11 14 15 19 19 +79 83 84 85 89 91 95 +11 15 17 21 23 30 +2 6 9 11 12 17 20 +32 36 37 39 44 46 45 +43 47 54 55 55 +8 12 15 22 25 26 30 +64 68 70 75 76 83 +52 59 60 61 62 +67 72 73 74 76 77 78 77 +74 81 82 83 84 86 86 +84 89 90 91 92 93 95 99 +46 53 56 57 64 +26 33 34 32 34 +1 8 7 9 12 14 17 16 +88 95 97 94 95 97 98 98 +49 56 57 55 59 +28 34 35 36 38 36 42 +20 26 26 28 31 +61 67 67 70 71 68 +56 63 63 64 66 66 +47 53 55 55 59 +59 64 67 70 72 72 77 +15 20 24 27 28 31 32 +50 57 61 62 64 61 +78 83 84 88 89 89 +34 39 41 45 48 52 +27 33 37 38 39 40 42 49 +22 28 30 31 36 37 +41 48 51 54 55 60 61 60 +74 80 81 84 90 90 +65 72 73 80 82 83 87 +50 57 62 64 71 +53 52 51 49 48 50 +40 38 37 36 34 32 32 +37 35 34 31 30 29 27 23 +85 82 79 76 75 74 72 66 +70 68 65 64 62 59 60 58 +59 57 55 52 50 53 52 55 +8 6 5 7 7 +88 87 85 86 82 +99 97 95 94 97 94 92 86 +33 31 31 29 28 +60 59 57 57 56 54 57 +82 79 79 76 74 71 71 +82 80 80 79 77 73 +61 58 57 57 51 +19 16 12 10 7 6 +46 45 43 40 36 37 +79 77 73 71 71 +26 25 24 20 16 +37 35 31 30 25 +63 60 59 54 52 51 49 47 +69 67 61 60 63 +92 91 86 84 84 +48 47 46 43 42 35 33 29 +82 80 79 77 70 69 68 61 +47 50 48 45 42 39 38 +29 32 30 29 26 29 +28 29 26 23 21 18 15 15 +90 91 88 87 84 83 79 +30 33 30 27 26 23 16 +76 78 77 76 74 75 74 71 +29 30 28 27 30 31 +67 70 67 68 66 66 +84 86 85 86 84 80 +29 30 29 28 31 26 +82 84 81 81 79 76 74 +54 56 56 55 58 +83 86 86 84 82 80 78 78 +27 28 28 26 24 20 +52 53 50 49 49 46 45 40 +30 33 31 30 29 25 24 +65 68 65 61 58 60 +61 64 60 57 55 52 52 +57 60 59 56 54 50 46 +75 76 75 71 64 +33 36 33 32 26 24 +18 19 13 12 10 13 +78 80 73 71 69 67 67 +24 26 24 18 15 11 +19 21 18 16 15 10 4 +21 21 18 17 16 +47 47 45 44 47 +24 24 22 21 21 +58 58 57 54 51 49 45 +62 62 61 59 57 56 50 +61 61 59 60 58 55 52 49 +41 41 39 36 34 36 34 35 +77 77 79 78 78 +20 20 19 20 16 +44 44 41 38 41 35 +92 92 92 90 87 86 84 +31 31 31 29 26 24 23 26 +16 16 15 15 14 12 12 +78 78 78 76 72 +73 73 72 72 67 +90 90 88 87 85 81 80 79 +20 20 19 16 12 13 +62 62 58 55 52 52 +99 99 95 92 91 89 87 83 +80 80 76 75 74 67 +88 88 81 79 78 77 74 +53 53 46 44 46 +91 91 84 81 79 76 76 +29 29 22 20 19 16 13 9 +80 80 79 74 73 68 +81 77 76 75 74 71 +20 16 13 11 10 9 12 +40 36 33 32 31 28 28 +75 71 70 67 63 +62 58 55 53 46 +50 46 47 44 42 39 +50 46 43 45 44 46 +82 78 76 78 77 77 +55 51 50 49 47 44 45 41 +31 27 26 23 20 23 16 +25 21 21 20 17 14 +93 89 87 87 84 87 +10 6 4 4 4 +22 18 16 16 14 10 +40 36 34 32 32 30 24 +32 28 25 22 20 16 13 +24 20 19 18 14 13 10 13 +99 95 92 89 87 85 81 81 +71 67 65 61 57 +45 41 37 35 33 31 29 23 +49 45 38 35 33 32 29 +98 94 92 90 84 85 +72 68 63 61 58 55 55 +92 88 82 80 79 75 +94 90 85 82 80 78 75 69 +18 13 12 9 7 6 +47 41 39 37 35 34 31 33 +49 44 41 38 35 32 29 29 +38 33 30 27 23 +79 73 71 68 67 64 57 +66 60 59 58 57 59 57 55 +21 14 11 9 8 5 8 11 +54 49 46 48 45 44 44 +41 34 32 34 32 31 27 +69 63 64 62 61 55 +32 26 26 23 20 17 15 14 +20 15 12 12 10 13 +88 83 82 80 78 75 75 75 +94 89 88 88 86 82 +52 46 45 44 44 38 +17 12 10 6 5 +61 56 54 52 48 49 +77 71 70 67 64 60 60 +62 57 55 52 48 47 46 42 +57 52 48 46 45 40 +97 92 90 87 81 80 79 +24 17 14 8 9 +76 70 67 62 62 +81 76 73 66 63 62 58 +98 92 89 84 82 76 +92 94 97 98 96 +52 53 55 56 59 61 62 62 +28 31 34 35 36 40 +23 26 28 31 38 +88 91 90 91 93 +64 66 67 64 67 65 +80 81 83 81 84 84 +88 90 91 89 93 +69 72 74 76 73 74 80 +9 11 13 13 15 17 18 +80 82 82 84 86 83 +15 17 17 19 20 21 24 24 +69 72 75 75 78 80 83 87 +69 71 72 75 77 77 80 85 +2 5 7 8 12 15 +73 75 78 82 81 +15 16 20 22 24 26 27 27 +38 39 42 43 44 48 52 +48 49 51 53 57 60 61 68 +39 40 42 44 50 51 52 +53 55 61 64 61 +87 89 95 98 99 99 +29 32 34 40 43 46 49 53 +1 2 8 9 12 15 21 +88 87 88 90 91 +63 61 64 66 68 65 +36 33 35 38 41 41 +19 18 21 23 25 27 28 32 +72 70 71 74 75 78 80 87 +25 24 27 24 25 28 +8 6 3 6 7 9 11 10 +30 29 27 28 29 32 32 +97 94 91 92 96 +75 74 71 72 78 +34 32 33 34 34 36 38 40 +75 73 73 74 73 +77 75 76 79 79 80 80 +52 50 50 53 54 58 +77 74 76 76 78 79 81 88 +84 83 85 89 91 +61 60 62 65 69 70 69 +39 37 38 40 43 47 50 50 +88 85 88 92 94 98 +43 41 44 48 55 +15 14 16 23 25 +49 46 47 48 49 56 54 +8 7 13 15 18 18 +52 49 50 55 56 57 59 63 +57 55 58 64 70 +53 53 55 57 59 61 64 +75 75 76 79 82 81 +89 89 91 93 95 97 98 98 +38 38 41 44 46 50 +3 3 4 6 9 10 13 20 +83 83 84 81 82 84 86 +26 26 23 24 25 24 +18 18 20 22 19 22 24 24 +51 51 53 54 53 56 59 63 +38 38 40 37 38 45 +50 50 50 52 54 +53 53 53 55 54 +53 53 54 56 56 56 +40 40 42 45 48 48 49 53 +79 79 79 82 84 86 87 92 +57 57 60 64 67 +12 12 15 18 22 19 +71 71 74 75 79 81 81 +13 13 17 18 20 21 24 28 +72 72 75 77 78 82 87 +59 59 60 66 67 +28 28 35 38 36 +89 89 95 96 96 +44 44 50 52 56 +59 59 65 68 70 75 +81 85 88 89 91 93 +67 71 72 74 75 78 79 77 +68 72 73 76 78 78 +5 9 11 12 15 19 +3 7 8 9 12 14 17 24 +19 23 21 22 24 25 +73 77 80 79 80 81 78 +66 70 71 72 71 71 +33 37 38 37 38 39 43 +84 88 87 90 95 +2 6 9 9 11 14 15 +2 6 6 8 6 +76 80 80 81 81 +46 50 53 54 54 58 +25 29 29 31 33 40 +64 68 72 75 78 81 +79 83 87 90 92 94 92 +8 12 14 18 20 20 +51 55 58 62 64 66 70 +31 35 39 42 49 +42 46 49 52 59 61 62 64 +34 38 40 45 48 49 52 51 +28 32 33 38 38 +10 14 16 19 20 27 31 +6 10 16 18 21 26 +56 61 63 65 68 71 73 +43 49 52 55 57 58 60 58 +81 87 90 93 96 98 98 +77 84 85 86 89 91 95 +72 78 80 82 83 90 +80 87 84 87 88 +22 28 27 30 31 29 +24 31 32 30 32 32 +9 15 12 15 18 21 24 28 +40 46 49 52 50 51 53 58 +62 67 68 69 69 72 74 +45 50 50 53 50 +91 96 97 97 97 +48 54 54 57 59 62 64 68 +48 53 56 58 60 63 63 68 +51 56 58 59 63 66 69 70 +32 38 39 40 42 46 48 46 +48 53 54 55 57 61 61 +7 13 16 17 18 22 26 +75 82 83 87 93 +15 22 23 30 33 34 36 37 +15 20 26 28 26 +31 37 39 42 44 47 53 53 +42 49 50 53 54 56 61 65 +32 39 46 49 54 +38 36 35 32 31 29 31 +34 31 29 26 24 24 +74 71 70 69 68 66 62 +67 65 63 61 58 55 49 +20 19 18 17 15 18 16 +47 44 42 45 46 +30 28 27 26 29 29 +64 61 64 62 58 +89 86 85 88 87 86 81 +36 33 32 29 26 24 24 23 +37 36 35 35 36 +63 61 59 56 55 54 54 54 +18 17 17 16 13 9 +30 29 27 27 24 17 +87 84 82 80 77 73 71 70 +29 27 24 20 19 18 20 +82 79 75 74 74 +59 58 55 51 47 +88 87 86 82 75 +91 89 86 81 78 +42 39 34 31 30 29 28 29 +98 97 96 89 89 +78 77 72 69 67 64 62 58 +88 86 84 82 79 76 70 64 +64 65 62 60 58 +82 85 84 81 78 77 80 +42 45 42 39 38 35 35 +95 97 95 94 90 +49 51 50 49 47 46 41 +38 41 43 40 39 +87 88 85 84 86 87 +21 24 23 21 20 22 19 19 +26 27 26 25 24 27 23 +88 91 90 89 88 91 89 83 +26 28 27 27 24 23 20 17 +58 59 58 55 55 54 55 +80 83 80 80 79 78 76 76 +55 58 58 55 54 50 +49 52 52 49 44 +46 47 45 41 38 35 33 +51 52 50 46 43 44 +8 10 8 7 6 2 1 1 +40 41 38 37 34 33 29 25 +96 97 96 92 90 84 +43 46 45 43 42 40 33 31 +39 41 34 32 31 33 +72 73 68 67 65 65 +33 35 33 30 29 22 19 15 +35 36 31 30 28 21 +57 57 55 52 49 +32 32 31 30 28 26 24 25 +66 66 64 62 59 56 55 55 +96 96 93 91 88 87 83 +50 50 48 47 46 43 41 34 +74 74 71 70 72 71 +12 12 13 10 7 9 +49 49 48 46 49 48 48 +60 60 59 61 57 +39 39 42 39 32 +34 34 34 33 32 31 30 27 +84 84 83 83 84 +17 17 17 15 13 11 11 +68 68 65 62 62 59 55 +23 23 20 20 19 12 +22 22 18 17 16 14 13 +85 85 82 79 77 73 76 +76 76 72 70 68 68 +76 76 72 70 67 65 61 +81 81 80 76 75 68 +35 35 32 30 23 21 19 16 +87 87 85 84 81 74 77 +24 24 21 14 14 +58 58 55 50 47 46 42 +92 92 91 88 83 78 +53 49 47 44 42 40 38 35 +37 33 30 27 26 24 22 24 +59 55 53 51 50 50 +69 65 64 61 60 58 54 +96 92 89 88 85 78 +91 87 88 86 84 83 80 77 +20 16 17 16 15 13 10 12 +66 62 65 62 59 59 +74 70 67 70 69 67 66 62 +78 74 73 71 73 71 66 +92 88 87 87 84 +16 12 9 7 6 6 5 7 +66 62 62 61 59 57 57 +51 47 45 44 42 42 38 +78 74 74 71 66 +74 70 69 65 64 63 60 59 +54 50 47 44 43 39 38 39 +78 74 73 72 68 68 +79 75 74 73 69 65 +18 14 10 8 1 +77 73 66 63 62 +97 93 92 86 87 +65 61 58 55 54 48 47 47 +71 67 65 62 55 54 50 +68 64 57 56 50 +83 78 76 74 72 71 69 +63 57 55 52 51 52 +56 50 47 44 43 41 41 +34 28 25 23 22 18 +93 87 85 83 80 79 77 72 +74 69 67 65 68 65 +77 71 70 68 71 72 +41 35 33 31 34 33 33 +52 47 44 41 39 37 40 36 +56 49 52 50 48 45 39 +89 83 82 81 80 80 79 +12 7 7 4 1 4 +99 92 90 90 89 86 86 +32 27 25 22 22 20 17 13 +30 25 23 23 22 21 14 +52 45 43 39 37 36 +91 86 84 80 79 76 75 78 +88 83 81 77 75 72 71 71 +49 43 39 37 33 +74 67 63 60 54 +84 79 76 74 68 67 66 64 +35 29 23 21 20 17 19 +28 22 19 17 16 9 9 +68 63 57 54 50 +26 21 18 17 12 10 5 +49 52 54 55 57 55 +44 46 48 50 53 56 57 57 +13 16 17 18 21 22 26 +62 64 67 69 71 72 73 79 +75 78 80 82 85 86 83 84 +21 22 20 22 23 25 28 27 +70 73 71 74 75 78 79 79 +66 68 70 69 72 75 78 82 +21 22 24 27 25 32 +29 32 35 36 37 37 40 43 +44 47 48 50 50 51 54 53 +63 64 66 66 67 67 +48 49 52 53 53 56 59 63 +64 66 69 70 71 72 72 79 +37 38 41 43 46 50 51 +81 84 86 87 91 89 +55 58 62 63 66 67 70 70 +59 60 63 65 69 70 73 77 +19 22 23 27 34 +25 26 33 36 37 +4 7 10 11 13 18 16 +25 28 31 32 33 38 38 +23 24 27 34 38 +34 35 36 42 45 46 47 52 +35 34 35 36 38 +70 69 71 72 74 75 73 +33 32 34 35 36 36 +65 64 66 69 72 75 77 81 +57 55 58 59 64 +14 13 11 12 13 +35 33 34 33 35 37 36 +57 55 52 55 55 +8 6 9 8 9 10 14 +32 29 26 29 35 +64 61 61 64 67 69 70 72 +86 85 87 87 90 92 89 +69 66 69 69 71 73 74 74 +21 19 19 20 24 +29 28 30 33 33 35 40 +48 47 48 50 54 56 58 +5 2 6 7 10 12 14 13 +35 32 33 37 39 42 42 +66 63 67 70 74 +71 68 69 73 79 +7 6 12 14 17 20 21 +54 51 54 61 59 +40 37 40 41 48 48 +30 29 34 37 39 43 +6 5 6 8 15 22 +3 3 4 7 10 11 +60 60 62 63 66 65 +89 89 92 94 97 99 99 +4 4 7 10 11 15 +72 72 73 76 77 84 +32 32 35 37 39 41 38 41 +74 74 76 75 78 81 82 80 +50 50 53 52 52 +78 78 77 78 82 +41 41 44 41 42 45 50 +64 64 66 66 67 +25 25 25 27 28 31 34 31 +24 24 24 27 29 29 +50 50 52 53 53 55 59 +6 6 8 11 11 18 +43 43 46 49 52 56 58 60 +29 29 32 36 38 41 44 41 +64 64 67 69 70 74 74 +13 13 17 18 21 24 28 +43 43 47 50 56 +43 43 46 52 54 +10 10 13 19 18 +87 87 90 96 96 +55 55 57 62 64 67 71 +16 16 19 21 23 28 35 +42 46 48 51 52 +65 69 71 72 71 +56 60 63 66 69 71 71 +35 39 42 44 48 +82 86 87 89 94 +28 32 31 33 34 +74 78 75 76 78 81 78 +30 34 36 34 34 +17 21 24 21 24 25 26 30 +4 8 9 12 10 15 +88 92 95 98 98 99 +46 50 50 53 54 55 52 +13 17 20 21 21 22 25 25 +49 53 53 55 58 62 +35 39 41 41 44 45 51 +79 83 84 88 90 +39 43 47 48 50 49 +78 82 83 87 88 91 94 94 +53 57 59 63 67 +50 54 58 61 66 +26 30 37 39 41 43 +73 77 80 82 85 87 92 90 +49 53 55 61 61 +13 17 20 22 23 26 31 35 +51 55 57 58 65 71 +53 60 62 64 67 69 72 75 +84 89 91 94 92 +36 42 45 46 48 48 +40 45 48 51 54 57 59 63 +48 53 56 57 60 63 66 71 +79 84 85 86 87 85 86 87 +87 94 92 95 93 +4 10 12 14 16 14 14 +31 36 35 38 39 40 42 46 +13 20 19 22 27 +33 38 38 41 43 44 +55 61 63 63 61 +41 46 48 51 54 54 56 56 +4 10 13 13 15 18 22 +33 38 40 43 44 45 45 50 +19 24 27 31 32 35 36 37 +85 90 91 95 93 +2 8 12 14 14 +51 58 62 63 64 68 +19 25 29 30 36 +9 14 15 20 23 24 27 29 +45 50 52 55 62 65 64 +35 42 43 49 49 +69 74 75 76 79 82 89 93 +48 55 58 60 61 66 71 +79 76 73 72 75 +70 69 68 66 64 64 +54 52 49 46 42 +86 85 84 82 79 78 71 +71 69 68 69 67 64 +63 60 59 58 60 59 62 +14 13 14 11 11 +96 94 93 96 92 +75 73 74 71 69 68 61 +71 70 67 67 65 63 62 +12 10 9 9 6 3 5 +82 79 78 76 75 74 74 74 +21 20 19 19 15 +44 43 43 42 35 +72 71 67 64 62 +53 51 49 45 47 +33 32 31 27 25 23 22 22 +88 85 84 80 76 +83 81 80 76 75 74 73 66 +49 46 43 41 40 35 34 31 +92 90 87 80 77 75 72 74 +84 82 80 79 72 71 69 69 +83 80 79 77 76 71 70 66 +50 49 48 45 38 37 30 +86 89 87 85 83 82 +59 62 61 59 56 59 +20 22 20 18 18 +77 80 79 76 73 71 67 +83 85 84 81 80 77 74 67 +25 28 30 27 24 +50 51 48 47 45 47 46 47 +83 84 82 85 82 80 80 +70 72 69 70 66 +80 83 82 84 82 79 74 +29 32 31 30 30 29 26 +72 74 71 70 70 69 70 +93 94 91 91 91 +44 45 43 41 38 36 36 32 +22 25 22 22 19 12 +18 21 19 15 13 12 11 +75 78 75 73 71 68 64 66 +77 80 76 73 73 +41 43 40 36 32 +43 46 45 44 40 37 32 +13 14 12 5 2 +72 73 72 70 63 65 +37 39 37 34 28 26 23 23 +54 55 54 51 48 42 40 36 +56 58 51 50 45 +19 19 17 15 13 12 +14 14 12 9 6 3 1 2 +85 85 82 80 78 78 +64 64 61 58 56 54 51 47 +30 30 29 27 21 +68 68 67 69 66 65 +21 21 20 19 18 21 22 +57 57 55 58 56 56 +71 71 69 66 69 67 63 +49 49 47 49 47 45 40 +78 78 76 76 75 +26 26 25 25 24 27 +90 90 90 88 88 +81 81 78 78 76 75 71 +26 26 23 23 21 19 13 +59 59 56 54 50 47 44 +60 60 57 53 56 +37 37 36 35 31 31 +37 37 36 34 30 29 25 +47 47 45 41 34 +18 18 13 10 8 6 3 +96 96 95 89 92 +84 84 82 77 77 +67 67 66 61 60 57 53 +20 20 14 12 6 +33 29 27 24 21 19 +12 8 6 4 1 3 +35 31 28 26 26 +66 62 60 58 54 +92 88 87 86 85 83 82 75 +91 87 84 87 85 82 80 +24 20 19 22 19 16 15 17 +60 56 58 55 52 51 51 +24 20 21 20 16 +34 30 28 30 29 27 20 +97 93 92 92 89 87 +48 44 43 43 40 39 42 +81 77 74 74 71 71 +81 77 76 75 72 69 69 65 +44 40 40 37 35 28 +93 89 87 83 80 77 +81 77 75 74 70 72 +86 82 78 76 76 +92 88 84 83 81 79 77 73 +38 34 30 28 22 +74 70 68 67 64 58 57 55 +92 88 83 82 80 83 +63 59 53 52 51 48 48 +56 52 46 44 43 39 +59 55 50 48 45 39 +77 70 67 65 62 60 57 +64 58 55 52 49 51 +71 66 65 63 63 +32 26 23 22 21 17 +80 73 70 67 61 +80 73 71 68 70 68 66 +94 88 86 88 87 86 85 87 +69 64 66 65 64 61 60 60 +39 32 34 33 29 +55 50 52 49 43 +96 90 88 85 84 84 81 79 +52 46 43 41 39 36 36 38 +18 13 10 10 9 7 7 +50 43 40 38 35 35 32 28 +72 65 64 63 63 57 +22 16 13 11 7 4 +39 33 29 27 26 28 +92 86 85 83 79 79 +31 26 25 21 20 18 14 +83 78 76 74 73 69 66 59 +33 28 25 20 19 17 +84 77 70 67 69 +49 43 42 41 34 31 31 +86 81 78 75 69 65 +63 57 54 47 44 39 +92 89 88 89 87 85 +21 21 22 20 22 25 28 +77 73 71 68 67 69 71 +56 54 55 53 55 57 55 +96 98 98 96 93 91 88 +58 58 56 55 51 50 46 +93 89 83 80 79 74 +41 41 43 49 50 54 +43 45 46 49 52 56 +23 21 16 13 15 +36 30 30 27 23 +46 39 38 36 35 34 31 +4 8 13 15 19 +69 69 68 65 59 58 54 +40 34 33 30 26 24 20 +53 54 52 48 47 +72 75 77 75 72 71 70 +34 32 34 35 38 41 44 44 +14 11 10 11 18 +29 31 28 23 22 20 19 22 +60 64 66 69 72 74 76 77 +30 27 28 30 30 34 +24 24 25 29 30 33 37 +64 63 65 66 68 70 72 71 +52 51 48 47 41 +15 15 14 12 10 7 2 +78 75 77 81 80 +11 8 9 10 12 +89 90 88 85 84 81 76 +16 20 20 22 24 27 30 35 +51 58 62 64 65 69 +80 84 85 87 88 92 97 +61 61 65 66 69 71 72 +27 27 28 29 30 32 35 32 +54 51 48 47 47 46 43 39 +25 22 21 18 11 8 5 +86 88 91 92 93 +48 51 54 57 58 61 64 66 +98 96 94 91 89 +14 16 18 21 24 26 +27 30 32 34 37 40 41 43 +79 80 81 83 86 87 +96 94 93 90 87 +68 71 74 75 78 80 83 85 +59 61 64 66 68 70 72 +24 26 29 31 33 35 38 +45 47 49 50 53 55 +15 18 20 23 24 +96 93 91 90 89 87 85 +51 54 55 58 61 62 65 66 +85 83 81 79 76 +63 66 68 70 73 76 79 +44 42 40 38 35 34 33 30 +61 63 64 65 66 69 +26 27 29 32 35 38 39 +36 39 41 42 43 +83 82 81 80 79 78 75 +42 41 38 35 34 31 30 28 +27 28 30 32 35 37 38 40 +82 81 78 76 74 72 70 69 +80 78 76 74 71 69 68 +90 93 96 98 99 +6 9 11 14 17 +59 58 56 54 52 +85 87 89 90 91 +49 46 43 40 39 36 +25 27 30 32 34 +87 86 83 81 78 75 +65 66 67 68 69 71 +18 17 16 13 11 8 6 3 +27 25 23 22 21 20 17 +45 43 41 38 35 33 31 +67 69 71 73 75 +23 21 20 19 18 16 15 14 +6 9 11 14 16 +15 18 19 22 23 26 +4 7 8 10 13 +43 44 46 47 48 +39 37 35 32 30 27 26 25 +53 55 56 59 61 64 66 +33 36 39 40 43 46 49 51 +91 93 95 96 97 98 99 +17 15 12 11 8 6 3 +54 57 59 62 65 68 +44 47 50 51 53 55 +47 48 51 54 57 60 62 +69 67 64 63 61 58 56 55 +84 85 86 88 89 90 91 +77 76 74 73 70 +87 86 85 82 81 +83 82 79 77 76 74 72 +53 51 49 48 46 44 41 +50 48 46 44 43 40 37 +27 25 23 21 20 19 17 +74 76 78 81 82 84 87 +79 76 75 72 69 +53 51 50 47 45 +37 35 32 31 30 28 27 +40 38 37 35 32 29 27 26 +61 64 66 69 72 75 77 +67 66 63 62 59 56 +39 42 44 45 48 50 52 +8 7 6 5 2 +84 82 81 79 76 75 +96 94 92 90 88 85 83 81 +60 63 64 67 69 +63 65 67 70 73 +64 65 66 69 71 +12 13 16 17 18 19 20 +54 57 59 62 64 65 +69 67 66 63 61 60 58 57 +52 51 50 48 46 +31 28 27 25 22 19 18 +25 24 22 20 17 16 15 13 +14 12 10 8 7 5 +12 14 17 18 19 21 22 +19 18 16 14 11 8 6 4 +94 92 89 88 86 +31 28 27 25 22 +51 50 49 47 45 43 40 39 +19 18 15 14 12 +11 12 14 15 18 20 +69 67 65 64 61 59 57 54 +94 93 91 90 87 +76 75 72 69 68 65 63 60 +65 67 68 70 71 74 +87 85 84 81 79 78 75 +78 75 73 71 70 67 66 +72 74 77 79 82 83 +24 25 27 28 29 32 35 36 +88 86 85 82 80 78 75 73 +48 46 44 41 40 +77 79 80 83 85 86 +22 25 28 31 33 34 37 +78 75 74 72 69 67 64 +37 40 43 45 48 51 54 57 +50 52 54 57 59 61 +57 60 63 64 67 68 +77 76 75 73 71 +83 82 81 79 76 73 +11 14 15 16 17 19 20 21 +15 14 11 9 8 5 +63 62 59 56 54 51 +14 13 10 8 6 3 +31 29 26 23 21 19 +69 68 66 64 62 61 58 56 +8 10 11 14 15 18 +34 31 30 28 25 +59 58 56 55 54 52 51 +61 62 64 67 69 +87 90 91 94 95 96 97 +18 19 22 23 25 27 +66 67 70 71 73 75 76 +98 95 93 92 89 87 +18 15 14 12 10 +91 90 87 85 84 82 +96 95 92 90 89 +18 17 14 11 8 5 +28 31 32 33 35 38 41 43 +27 26 25 23 20 17 +54 52 51 50 48 46 45 43 +96 93 92 91 88 85 82 +81 84 85 88 90 +30 29 26 25 23 20 19 16 +12 14 17 20 22 24 27 28 +61 59 57 56 54 52 +57 60 61 63 64 67 +33 34 37 39 41 +29 31 34 36 37 +58 59 61 63 66 68 69 +30 31 33 35 36 +64 63 60 58 57 55 52 +40 43 46 47 49 51 +22 19 16 15 12 10 +41 40 38 36 33 +77 78 79 81 82 83 86 +51 50 47 46 43 40 39 38 +59 62 63 65 68 71 73 +58 61 64 66 69 71 +28 27 26 23 20 18 15 +29 26 24 23 20 19 18 15 +89 90 92 93 94 +75 73 72 71 68 +35 32 29 27 24 22 19 18 +44 43 40 39 37 36 33 31 +98 97 96 94 93 91 90 89 +53 51 49 46 44 41 38 +76 77 78 79 80 83 84 +84 86 89 92 93 96 +31 34 35 37 40 41 +12 11 9 6 4 3 2 1 +80 83 86 89 91 94 95 98 +17 18 19 20 22 24 +20 23 24 26 27 30 +61 60 59 58 56 54 51 +10 8 5 3 1 +39 37 34 33 31 28 25 +83 82 80 78 77 74 71 68 +70 67 64 61 60 +82 84 87 90 91 92 95 +11 13 15 18 20 23 24 +87 84 82 80 77 76 75 72 +47 44 41 39 36 33 +9 12 13 14 15 18 +24 22 20 18 17 +77 80 81 83 86 87 90 91 +54 55 57 58 60 63 +30 27 25 22 21 19 16 +35 33 32 31 30 +31 28 25 22 20 19 18 +29 31 32 33 35 +72 75 78 80 83 85 86 +82 80 78 77 74 +20 18 15 12 10 7 6 +38 41 43 46 49 50 51 +52 54 57 60 62 +57 59 60 61 63 64 67 70 +11 12 15 16 18 +2 4 6 7 9 12 +36 38 40 41 44 +22 25 27 30 32 34 36 39 +71 72 73 76 79 80 +68 71 72 75 78 81 84 86 +69 70 73 76 78 80 +40 38 36 33 31 28 25 23 +5 6 8 10 13 16 +30 28 26 25 22 +30 27 26 23 21 20 +19 20 22 23 25 26 28 29 +74 71 69 66 63 61 +22 23 25 26 28 29 31 32 +9 10 12 14 15 17 20 +16 14 13 12 10 +91 90 89 87 85 83 81 79 +56 54 53 50 48 +43 42 41 40 37 34 33 31 +92 89 87 85 83 82 +28 26 25 24 21 18 15 +73 74 76 77 78 81 +89 86 83 81 80 77 74 73 +34 35 38 41 42 45 48 50 +18 15 12 9 8 +69 67 66 64 62 60 +35 37 38 39 40 41 +93 94 95 97 98 +48 49 52 54 55 58 59 +28 29 30 32 33 34 35 37 +92 90 88 86 85 84 +26 27 30 33 35 38 +45 47 49 52 54 57 +69 68 66 63 61 60 57 +69 68 66 64 63 +6 7 8 11 12 14 16 19 +61 63 65 66 67 70 73 75 +87 85 84 82 80 +93 92 91 88 87 86 85 diff --git a/crates/day_2/data/test_input b/crates/day_2/data/test_input new file mode 100644 index 0000000..82cd679 --- /dev/null +++ b/crates/day_2/data/test_input @@ -0,0 +1,6 @@ +7 6 4 2 1 +1 2 7 8 9 +9 7 6 2 1 +1 3 2 4 5 +8 6 4 4 1 +1 3 6 7 9 \ No newline at end of file diff --git a/crates/day_2/src/day_2.rs b/crates/day_2/src/day_2.rs new file mode 100644 index 0000000..7ad9bc6 --- /dev/null +++ b/crates/day_2/src/day_2.rs @@ -0,0 +1,113 @@ + +/****************************************************************************** +* @file day_2.rs +* @author Joey Pollack +* @date 2024/12/03 (y/m/d) +* @modified 2024/12/03 (y/m/d) +* @copyright Joseph R Pollack +* @brief Advent of Code 2024 day 2 problems +******************************************************************************/ + +use crate::report::Report; +use ::solver_base::solver_base::{Solver, DataSet, RunMode}; +use utils::utils; + +pub struct Day2 +{ + data_set: DataSet, + run_mode: RunMode, + do_debug_prints: bool, + reports: Vec, + pub final_result: i32, +} + +//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +// DAY 2 IMPL +//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +impl Day2 +{ + pub fn new() -> Day2 + { + Day2 { data_set: DataSet::Test, run_mode: RunMode::FirstCase, do_debug_prints: false, reports: vec![], final_result: 0 } + } + + fn solve_first_case(self: &mut Self) -> String + { + // TODO: Day2::solve_first_case + + self.final_result.to_string() + } + + fn solve_second_case(self: &mut Self) -> String + { + // TODO: Day2::solve_second_case + + self.final_result.to_string() + } +} + +//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +// SOLVER TRAIT IMPL +//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +impl Solver for Day2 +{ + fn print_test() + { + println!("DAY 2 TEST PRINT"); + } + + fn init(self: &mut Self, data_set: DataSet, run_mode: RunMode, enable_debug_prints: bool) + { + self.run_mode = run_mode; + self.do_debug_prints = enable_debug_prints; + + let dir = utils::get_working_dir(); + let data_filename = + match self.data_set + { + DataSet::Test => format!("{}/data/test_input", dir), + DataSet::Full => format!("{}/data/input", dir), + }; + + + let data = utils::load_data(&data_filename); + for r in data.split("\n") + { + if self.do_debug_prints + { + println!("Raw report: {}", r); + } + + let mut lvl_list: Vec = vec![]; + for value in r.split(" ") + { + lvl_list.push(value.parse::().unwrap()); + } + + if self.do_debug_prints + { + println!("Processed report: {:#?}", lvl_list); + } + + self.reports.push(Report::new(lvl_list)); + } + + } + + fn solve(self: &mut Self) -> String + { + match self.run_mode + { + RunMode::FirstCase => + { + self.solve_first_case() + }, + + RunMode::SecondCase => + { + self.solve_second_case() + } + } + } + +} \ No newline at end of file diff --git a/crates/day_2/src/lib.rs b/crates/day_2/src/lib.rs new file mode 100644 index 0000000..3e9c7f2 --- /dev/null +++ b/crates/day_2/src/lib.rs @@ -0,0 +1,3 @@ + +pub mod day_2; +pub (crate) mod report; \ No newline at end of file diff --git a/crates/day_2/src/report.rs b/crates/day_2/src/report.rs new file mode 100644 index 0000000..ea765b3 --- /dev/null +++ b/crates/day_2/src/report.rs @@ -0,0 +1,31 @@ + + +#[derive(Copy, Clone, PartialEq, Debug)] +pub enum Status +{ + Safe, + Unsafe, + Unknown, +} + +#[derive(Clone, Debug)] +pub struct Report +{ + levels: Vec, + status: Status, +} + +impl Report +{ + pub fn new(lvls: Vec) -> Report + { + Report { levels: lvls , status: Status::Unknown } + } + + pub fn analyze(self: &mut Report) -> Status + { + // TODO: Report::analyze() + + Status::Unknown + } +} \ No newline at end of file diff --git a/crates/day_3/Cargo.toml b/crates/day_3/Cargo.toml new file mode 100644 index 0000000..ad0bad2 --- /dev/null +++ b/crates/day_3/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "day_3" +description = "Day 3 of the Advent of Code 2024" +version = "0.1.0" +edition = "2021" + +[dependencies] +solver_base = { workspace = true } +utils = { workspace = true } \ No newline at end of file diff --git a/crates/day_3/build.rs b/crates/day_3/build.rs new file mode 100644 index 0000000..4cd9495 --- /dev/null +++ b/crates/day_3/build.rs @@ -0,0 +1,33 @@ + +use std::{env, fs, path::Path}; + +fn main() +{ + // let out_dir = env::var("OUT_DIR").unwrap(); + // let cwd = env::var("CARGO_MANIFEST_DIR").unwrap(); + // println!("CWD: {}\n", cwd); + // let data_dir = cwd + "\\data"; + // let data_path = Path::new(&data_dir); + // println!("Data path: {}", data_path.to_string_lossy()); + + // let data_path = Path::new("data/test_input"); + + // let out_dir = env::var("OUT_DIR").unwrap(); + // panic!("out_dir: {}", out_dir); + let out_path = format!("../../target/{}", &env::var("PROFILE").unwrap()); + let out_path = Path::new(&out_path); + //let out_path = Path::new(&out_dir).join(&env::var("PROFILE").unwrap()); + let out_path_data = out_path.join(Path::new("data")); + + if !out_path_data.exists() + { + fs::create_dir(&out_path_data).expect(&format!("Could not create data directory at: {}", out_path_data.to_string_lossy())); + } + + for file in fs::read_dir("data").unwrap() + { + let file = file.unwrap(); + let dest = out_path.join(file.path()); + fs::copy(file.path(), &dest).expect(&format!("Could not copy file {} to {}", file.path().to_string_lossy(), dest.to_string_lossy())); + } +} \ No newline at end of file diff --git a/crates/day_3/src/day_3.rs b/crates/day_3/src/day_3.rs new file mode 100644 index 0000000..b6aecf7 --- /dev/null +++ b/crates/day_3/src/day_3.rs @@ -0,0 +1,92 @@ + +/****************************************************************************** +* @file day_3.rs +* @author Joey Pollack +* @date 2024/12/03 (y/m/d) +* @modified 2024/12/03 (y/m/d) +* @copyright Joseph R Pollack +* @brief Advent of Code 2024 day 3 problems +******************************************************************************/ + +use ::solver_base::solver_base::{Solver, DataSet, RunMode}; +use utils::utils; + +pub struct Day3 +{ + data_set: DataSet, + run_mode: RunMode, + do_debug_prints: bool, + pub final_result: i32, +} + +//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +// DAY 3 IMPL +//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +impl Day3 +{ + pub fn new() -> Day3 + { + Day3 { data_set: DataSet::Test, run_mode: RunMode::FirstCase, do_debug_prints: false, final_result: 0 } + } + + fn solve_first_case(self: &mut Self) -> String + { + + self.final_result.to_string() + } + + fn solve_second_case(self: &mut Self) -> String + { + + + self.final_result.to_string() + } +} + +//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +// SOLVER TRAIT IMPL +//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +impl Solver for Day3 +{ + fn print_test() + { + println!("DAY 3 TEST PRINT"); + } + + fn init(self: &mut Self, data_set: DataSet, run_mode: RunMode, enable_debug_prints: bool) + { + self.run_mode = run_mode; + self.do_debug_prints = enable_debug_prints; + + let dir = utils::get_working_dir(); + let data_filename = + match self.data_set + { + DataSet::Test => format!("{}/data/test_input", dir), + DataSet::Full => format!("{}/data/input", dir), + }; + + + let _data = utils::load_data(&data_filename); + + // TODO: Day3::init + + } + + fn solve(self: &mut Self) -> String + { + match self.run_mode + { + RunMode::FirstCase => + { + self.solve_first_case() + }, + + RunMode::SecondCase => + { + self.solve_second_case() + } + } + } + +} \ No newline at end of file diff --git a/crates/day_3/src/lib.rs b/crates/day_3/src/lib.rs new file mode 100644 index 0000000..96b85f1 --- /dev/null +++ b/crates/day_3/src/lib.rs @@ -0,0 +1,2 @@ + +pub mod day_3; \ No newline at end of file diff --git a/crates/solver_base/src/solver_base.rs b/crates/solver_base/src/solver_base.rs index e8b5321..c2f6128 100644 --- a/crates/solver_base/src/solver_base.rs +++ b/crates/solver_base/src/solver_base.rs @@ -3,12 +3,17 @@ #[derive(Copy, Clone, Debug, PartialEq)] pub enum RunMode { - FirstCaseTest, FirstCase, - SecondCaseTest, SecondCase, } +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum DataSet +{ + Test, + Full, +} + pub trait Solver { @@ -18,6 +23,6 @@ pub trait Solver println!("SOLVER BASE PRINT TEST"); } - fn init(self: &mut Self, run_mode: RunMode, enable_debug_prints: bool); + fn init(self: &mut Self, data_set: DataSet, run_mode: RunMode, enable_debug_prints: bool); fn solve(self: &mut Self) -> String; } diff --git a/src/main.rs b/src/main.rs index a7d003f..e7afca8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,18 +1,34 @@ - +/****************************************************************************** +* @file main.rs +* @author Joey Pollack +* @date 2024/12/03 (y/m/d) +* @modified 2024/12/03 (y/m/d) +* @copyright Joseph R Pollack +* @brief Advent of Code 2024 main file +******************************************************************************/ use day_1::day_1::Day1; -use solver_base::solver_base::{Solver, RunMode}; +use day_2::day_2::Day2; +use solver_base::solver_base::{Solver, DataSet, RunMode}; fn main() { + // DAY 1 let mut day_1 = Day1::new(); - day_1.init(RunMode::FirstCase, false); + day_1.init(DataSet::Full, RunMode::FirstCase, false); let day1_result = day_1.solve(); println!("Day1 Part 1 Final Result: {}", day1_result); let mut day_1 = Day1::new(); - day_1.init(RunMode::SecondCase, false); + day_1.init(DataSet::Full, RunMode::SecondCase, false); let day1_result = day_1.solve(); println!("Day1 Part 2 Final Result: {}", day1_result); + + // DAY 2 + let mut day_2 = Day2::new(); + day_2.init(DataSet::Full, RunMode::FirstCase, true); + let day2_result = day_2.solve(); + println!("Day2 Part 1 Final Result: {}", day2_result); + }