diff --git a/2015/Cargo.toml b/2015/Cargo.toml new file mode 100644 index 0000000..b8540a5 --- /dev/null +++ b/2015/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name="aoc2015" +version = "0.1.0" +edition = "2024" + +[dependencies] +core = { path = "../core" } +md-5 = { workspace = true } \ No newline at end of file diff --git a/src/bin/2015_01a.rs b/2015/src/bin/2015_01a.rs similarity index 98% rename from src/bin/2015_01a.rs rename to 2015/src/bin/2015_01a.rs index bf29753..e2c70c4 100644 --- a/src/bin/2015_01a.rs +++ b/2015/src/bin/2015_01a.rs @@ -22,7 +22,7 @@ // To what floor do the instructions take Santa? // -use aoc::read_data; +use core::read_data; fn main() { let instructions = read_data("2015_01_data.txt"); diff --git a/src/bin/2015_01b.rs b/2015/src/bin/2015_01b.rs similarity index 97% rename from src/bin/2015_01b.rs rename to 2015/src/bin/2015_01b.rs index 4116f18..b17312b 100644 --- a/src/bin/2015_01b.rs +++ b/2015/src/bin/2015_01b.rs @@ -7,8 +7,7 @@ // What is the position of the character that causes Santa to first enter the basement? // -use aoc::read_data; - +use core::read_data; fn main() { let instructions = read_data("2015_01_data.txt"); diff --git a/src/bin/2015_02a.rs b/2015/src/bin/2015_02a.rs similarity index 96% rename from src/bin/2015_02a.rs rename to 2015/src/bin/2015_02a.rs index 7b8fcb6..9f38af2 100644 --- a/src/bin/2015_02a.rs +++ b/2015/src/bin/2015_02a.rs @@ -17,7 +17,7 @@ // they order? // -use aoc::{read_data, smallest_of_vec, string_to_3u32, sum_of_vec}; +use core::{read_data, smallest_of_vec, string_to_3u32, sum_of_vec}; fn calculate_wrapping_needed(length: u32, width: u32, height: u32) -> u32 { let sides = vec![ diff --git a/src/bin/2015_02b.rs b/2015/src/bin/2015_02b.rs similarity index 93% rename from src/bin/2015_02b.rs rename to 2015/src/bin/2015_02b.rs index 61e5445..7b6e280 100644 --- a/src/bin/2015_02b.rs +++ b/2015/src/bin/2015_02b.rs @@ -15,7 +15,7 @@ // How many total feet of ribbon should they order? // -use aoc::{read_data, string_to_3u32}; +use core::{read_data, string_to_3u32}; fn bow_ribbon_length(l: u32, w: u32, h: u32) -> u32 { l * w * h @@ -35,7 +35,8 @@ fn main() { println!("Box sized {} requires {}", "2x3x4", ribbon_for_package(2,3,4)); println!("Box sized {} requires {}", "1x1x10", ribbon_for_package(1,1,10)); - let sizes = read_data("2015_02_data.txt").lines(); + let binding = read_data("2015_02_data.txt"); + let sizes = binding.lines(); let mut total_ribbon = 0; for size in sizes { diff --git a/src/bin/2015_03a.rs b/2015/src/bin/2015_03a.rs similarity index 89% rename from src/bin/2015_03a.rs rename to 2015/src/bin/2015_03a.rs index c3aa365..f4a6163 100644 --- a/src/bin/2015_03a.rs +++ b/2015/src/bin/2015_03a.rs @@ -17,7 +17,7 @@ // ^v^v^v^v^v delivers a bunch of presents to some very lucky children at only 2 houses. use std::collections::HashMap; -use aoc::read_data; +use core::read_data; fn main() { let mut visits: HashMap = HashMap::from([("0x0".to_string(), 1)]); @@ -27,19 +27,19 @@ fn main() { for current_instruction in instructions.chars() { match current_instruction { '^' => { - println!("Move North 1"); + //println!("Move North 1"); current_y += 1; }, 'v' => { - println!("Move South 1"); + //println!("Move South 1"); current_y -= 1; }, '<' => { - println!("Move West 1"); + //println!("Move West 1"); current_x -= 1; }, '>' => { - println!("Move East 1"); + //println!("Move East 1"); current_x += 1; }, _ => { unreachable!("Invalid instruction -> {}", ¤t_instruction); } @@ -49,7 +49,5 @@ fn main() { } println!("Found {} houses got presents.", visits.keys().count()); - - println!("Taxation is theft."); } // 2081 \ No newline at end of file diff --git a/src/bin/2015_03b.rs b/2015/src/bin/2015_03b.rs similarity index 94% rename from src/bin/2015_03b.rs rename to 2015/src/bin/2015_03b.rs index f9bb9ae..be67082 100644 --- a/src/bin/2015_03b.rs +++ b/2015/src/bin/2015_03b.rs @@ -15,7 +15,7 @@ // going the other. use std::collections::HashMap; -use aoc::read_data; +use core::read_data; fn num_houses(directions: &str) -> u32 { let (mut santa_x, mut santa_y, mut robo_x, mut robo_y) = (0,0,0,0); @@ -59,7 +59,7 @@ fn num_houses(directions: &str) -> u32 { } else { format!("{}x{}", robo_x, robo_y) }; - println!("V:{} S:{}x{} R:{}x{} V#:{}", current_address, santa_x, santa_y, robo_x, robo_y, visits.keys().count()); + //println!("V:{} S:{}x{} R:{}x{} V#:{}", current_address, santa_x, santa_y, robo_x, robo_y, visits.keys().count()); *visits.entry(current_address).and_modify(|x| *x += 1).or_insert(1); santas_turn = !santas_turn; } diff --git a/src/bin/2015_04a.rs b/2015/src/bin/2015_04a.rs similarity index 99% rename from src/bin/2015_04a.rs rename to 2015/src/bin/2015_04a.rs index 1647d8d..8f71dd2 100644 --- a/src/bin/2015_04a.rs +++ b/2015/src/bin/2015_04a.rs @@ -42,3 +42,4 @@ fn main() { } } } +// 254575 \ No newline at end of file diff --git a/src/bin/2015_04b.rs b/2015/src/bin/2015_04b.rs similarity index 98% rename from src/bin/2015_04b.rs rename to 2015/src/bin/2015_04b.rs index b6d2889..51827c9 100644 --- a/src/bin/2015_04b.rs +++ b/2015/src/bin/2015_04b.rs @@ -29,4 +29,5 @@ fn main() { } } } -} \ No newline at end of file +} +// 1048970 diff --git a/src/bin/2015_05a.rs b/2015/src/bin/2015_05a.rs similarity index 99% rename from src/bin/2015_05a.rs rename to 2015/src/bin/2015_05a.rs index b0a7e97..012b7d5 100644 --- a/src/bin/2015_05a.rs +++ b/2015/src/bin/2015_05a.rs @@ -19,7 +19,7 @@ // How many strings are nice? // -use aoc::read_data; +use core::read_data; fn no_banned_parts(to_check: &str) -> bool { !to_check.contains("ab") && diff --git a/src/bin/2015_05b.rs b/2015/src/bin/2015_05b.rs similarity index 68% rename from src/bin/2015_05b.rs rename to 2015/src/bin/2015_05b.rs index 7153dfc..8e1fea3 100644 --- a/src/bin/2015_05b.rs +++ b/2015/src/bin/2015_05b.rs @@ -20,32 +20,30 @@ // ieodomkazucvgmuy is naughty because it has a repeating letter with one between (odo), but no // pair that appears twice. -fn appears_twice_without_overlapping(to_check: &str) -> bool { - let mut to_find = vec![]; - for index in 0..=to_check.len() - 1 { - let next_pair = to_check.chars().enumerate(); - println!("Index {index} = {:?}", next_pair); - } +use core::read_data; - true + +fn appears_twice_without_overlapping(to_check: &str) -> bool { + let check_chars: Vec<_> = to_check.chars().collect(); + for index in 0.. check_chars.len() - 1 { + let pair = (check_chars[index], check_chars[index + 1]); + for subindex in index + 2 .. check_chars.len() - 1 { + if check_chars[subindex] == pair.0 && check_chars[subindex + 1] == pair.1 { + return true; + } + } + } + false } fn letter_repeated_seperated_by_1(to_check: &str) -> bool { - println!("Starting to check for XyX"); - let mut has_criteria = false; - - let mut two_back = ' '; - let mut one_back = ' '; - for (index, current) in to_check.chars().enumerate() { - if current == two_back { - has_criteria = true; - println!("Found a seperated pair. {index} / {to_check}"); - break; + let chars: Vec<_> = to_check.chars().collect(); + for index in 0..chars.len() - 2 { + if chars[index] == chars[index + 2] { + return true } - two_back = one_back; - one_back = current; } - has_criteria + false } fn is_nice(to_check: &str) -> bool { @@ -58,4 +56,16 @@ fn main() { println!("xxyxx is nice -> {}", is_nice("xxyxx")); println!("uurcxstgmygtbstg is NOT nice -> {}", is_nice("uurcxstgmygtbstg")); println!("ieodomkazucvgmuy is NOT nice -> {}", is_nice("ieodomkazucvgmuy")); + + let binding = read_data("2015_05_data.txt"); + let lines = binding.lines(); + let mut num_lines = 0; + + for line in lines { + if is_nice(line) { + num_lines += 1; + } + } + println!("Found {num_lines} good passwords."); + } diff --git a/src/bin/2015_06a.rs b/2015/src/bin/2015_06a.rs similarity index 99% rename from src/bin/2015_06a.rs rename to 2015/src/bin/2015_06a.rs index fdc0e9d..254732c 100644 --- a/src/bin/2015_06a.rs +++ b/2015/src/bin/2015_06a.rs @@ -21,7 +21,7 @@ // turn off 499,499 through 500,500 would turn off (or leave off) the middle four lights. // After following the instructions, how many lights are lit? -use aoc::read_data; +use core::read_data; fn main() { let mut block: [bool; 1000*1000] = [false; 1000*1000]; diff --git a/src/bin/2015_06b.rs b/2015/src/bin/2015_06b.rs similarity index 99% rename from src/bin/2015_06b.rs rename to 2015/src/bin/2015_06b.rs index 0942106..0a5dbec 100644 --- a/src/bin/2015_06b.rs +++ b/2015/src/bin/2015_06b.rs @@ -18,7 +18,7 @@ // turn on 0,0 through 0,0 would increase the total brightness by 1. // toggle 0,0 through 999,999 would increase the total brightness by 2000000. -use aoc::read_data; +use core::read_data; fn main() { let mut block: Box<[u32; 1000*1000]> = Box::new([0; 1000*1000]); diff --git a/src/bin/2015_08a.rs b/2015/src/bin/2015_08a.rs similarity index 98% rename from src/bin/2015_08a.rs rename to 2015/src/bin/2015_08a.rs index 3fd8a47..3b7dfd0 100644 --- a/src/bin/2015_08a.rs +++ b/2015/src/bin/2015_08a.rs @@ -1,4 +1,4 @@ -use aoc::read_data; +use core::read_data; fn main() { let binding = read_data("2015_08_data.txt"); diff --git a/src/bin/2015_10a.rs b/2015/src/bin/2015_10a.rs similarity index 100% rename from src/bin/2015_10a.rs rename to 2015/src/bin/2015_10a.rs diff --git a/src/bin/2015_14a.rs b/2015/src/bin/2015_14a.rs similarity index 100% rename from src/bin/2015_14a.rs rename to 2015/src/bin/2015_14a.rs diff --git a/2016/Cargo.toml b/2016/Cargo.toml new file mode 100644 index 0000000..7625877 --- /dev/null +++ b/2016/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name="aoc2016" +version = "0.1.0" +edition = "2024" + +[dependencies] +core = { path = "../core" } +md-5 = { workspace = true } \ No newline at end of file diff --git a/src/bin/2016_01a.rs b/2016/src/bin/2016_01a.rs similarity index 99% rename from src/bin/2016_01a.rs rename to 2016/src/bin/2016_01a.rs index 3dd0a07..2e74c8c 100644 --- a/src/bin/2016_01a.rs +++ b/2016/src/bin/2016_01a.rs @@ -27,7 +27,7 @@ // use std::{env, fs}; -use aoc::read_data; +use core::read_data; use crate::CardinalDirection::*; #[derive(Debug)] diff --git a/src/bin/2016_01b.rs b/2016/src/bin/2016_01b.rs similarity index 99% rename from src/bin/2016_01b.rs rename to 2016/src/bin/2016_01b.rs index 3f4722a..938f565 100644 --- a/src/bin/2016_01b.rs +++ b/2016/src/bin/2016_01b.rs @@ -28,7 +28,7 @@ use std::{env, fs}; use std::collections::HashMap; -use aoc::read_data; +use core::read_data; use crate::CardinalDirection::*; fn manhattan_distance(directions: &str) -> i32 { diff --git a/src/bin/2016_02a.rs b/2016/src/bin/2016_02a.rs similarity index 99% rename from src/bin/2016_02a.rs rename to 2016/src/bin/2016_02a.rs index 2a828b8..37911d6 100644 --- a/src/bin/2016_02a.rs +++ b/2016/src/bin/2016_02a.rs @@ -32,7 +32,7 @@ // Your puzzle input is the instructions from the document you found at the front desk. What is the bathroom code? // -use aoc::read_data; +use core::read_data; #[derive(Debug)] struct Location { diff --git a/src/bin/2016_03a.rs b/2016/src/bin/2016_03a.rs similarity index 98% rename from src/bin/2016_03a.rs rename to 2016/src/bin/2016_03a.rs index 8b92861..1656525 100644 --- a/src/bin/2016_03a.rs +++ b/2016/src/bin/2016_03a.rs @@ -12,7 +12,7 @@ // example, the "triangle" given above is impossible, because 5 + 10 is not larger than 25. // -use aoc::read_data; +use core::read_data; // the total of the sides minus the largest side is greater then the longest side fn possibly_valid_triangle(a: u32, b: u32, c: u32) -> bool { diff --git a/src/bin/2016_03b.rs b/2016/src/bin/2016_03b.rs similarity index 98% rename from src/bin/2016_03b.rs rename to 2016/src/bin/2016_03b.rs index 3c42800..36cd6a6 100644 --- a/src/bin/2016_03b.rs +++ b/2016/src/bin/2016_03b.rs @@ -1,4 +1,4 @@ -use aoc::read_data; +use core::read_data; // the total of the sides minus the largest side is greater then the longest side fn possibly_valid_triangle(a: u32, b: u32, c: u32) -> bool { diff --git a/src/bin/2016_04a.rs b/2016/src/bin/2016_04a.rs similarity index 98% rename from src/bin/2016_04a.rs rename to 2016/src/bin/2016_04a.rs index 226565d..141f8aa 100644 --- a/src/bin/2016_04a.rs +++ b/2016/src/bin/2016_04a.rs @@ -1,5 +1,5 @@ use std::collections::{BTreeMap, HashMap}; -use aoc::read_data; +use core::read_data; struct EncryptedRoom { encrypted_name: String, diff --git a/src/bin/2016_05a.rs b/2016/src/bin/2016_05a.rs similarity index 100% rename from src/bin/2016_05a.rs rename to 2016/src/bin/2016_05a.rs diff --git a/src/bin/2016_05b.rs b/2016/src/bin/2016_05b.rs similarity index 100% rename from src/bin/2016_05b.rs rename to 2016/src/bin/2016_05b.rs diff --git a/src/bin/2016_06a.rs b/2016/src/bin/2016_06a.rs similarity index 98% rename from src/bin/2016_06a.rs rename to 2016/src/bin/2016_06a.rs index 6e39998..62171f7 100644 --- a/src/bin/2016_06a.rs +++ b/2016/src/bin/2016_06a.rs @@ -32,7 +32,7 @@ // use std::collections::HashMap; -use aoc::read_data; +use core::read_data; fn main() { let binding = read_data("2016_06_data.txt"); diff --git a/src/bin/2016_06b.rs b/2016/src/bin/2016_06b.rs similarity index 98% rename from src/bin/2016_06b.rs rename to 2016/src/bin/2016_06b.rs index 88d085d..56e3f4d 100644 --- a/src/bin/2016_06b.rs +++ b/2016/src/bin/2016_06b.rs @@ -15,7 +15,7 @@ // use std::collections::HashMap; -use aoc::read_data; +use core::read_data; fn main() { let binding = read_data("2016_06_data.txt"); diff --git a/src/bin/2016_07a.rs b/2016/src/bin/2016_07a.rs similarity index 100% rename from src/bin/2016_07a.rs rename to 2016/src/bin/2016_07a.rs diff --git a/2017/Cargo.toml b/2017/Cargo.toml new file mode 100644 index 0000000..89c5cbb --- /dev/null +++ b/2017/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name="aoc2017" +version = "0.1.0" +edition = "2024" + +[dependencies] +core = { path = "../core" } diff --git a/src/bin/2017_01a.rs b/2017/src/bin/2017_01a.rs similarity index 98% rename from src/bin/2017_01a.rs rename to 2017/src/bin/2017_01a.rs index 1af5bad..15e2c45 100644 --- a/src/bin/2017_01a.rs +++ b/2017/src/bin/2017_01a.rs @@ -7,7 +7,7 @@ // 1234 produces 0 because no digit matches the next. // 91212129 produces 9 because the only digit that matches the next one is the last digit, 9. -use aoc::read_data; +use core::read_data; fn circular_digit_sum(input: &str) -> u32 { let mut running_total = 0; diff --git a/src/bin/2017_01b.rs b/2017/src/bin/2017_01b.rs similarity index 98% rename from src/bin/2017_01b.rs rename to 2017/src/bin/2017_01b.rs index 479a809..503a32b 100644 --- a/src/bin/2017_01b.rs +++ b/2017/src/bin/2017_01b.rs @@ -11,7 +11,7 @@ // 123123 produces 12. // 12131415 produces 4. -use aoc::read_data; +use core::read_data; fn halfway_sum_thing(input: &str) -> u32 { let mut running_total = 0; diff --git a/src/bin/2017_02a.rs b/2017/src/bin/2017_02a.rs similarity index 97% rename from src/bin/2017_02a.rs rename to 2017/src/bin/2017_02a.rs index 255ade6..3921966 100644 --- a/src/bin/2017_02a.rs +++ b/2017/src/bin/2017_02a.rs @@ -1,4 +1,4 @@ -use aoc::read_data; +use core::read_data; fn main() { let mut running_total = 0; diff --git a/src/bin/2017_04a.rs b/2017/src/bin/2017_04a.rs similarity index 97% rename from src/bin/2017_04a.rs rename to 2017/src/bin/2017_04a.rs index 5199a6d..59fab9e 100644 --- a/src/bin/2017_04a.rs +++ b/2017/src/bin/2017_04a.rs @@ -9,7 +9,7 @@ // use std::collections::HashMap; -use aoc::read_data; +use core::read_data; fn is_valid(input: &str) -> bool { let parts = input.split(' '); diff --git a/2018/Cargo.toml b/2018/Cargo.toml new file mode 100644 index 0000000..47bbc60 --- /dev/null +++ b/2018/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name="aoc2018" +version = "0.1.0" +edition = "2024" + +[dependencies] +core = { path = "../core" } diff --git a/src/bin/2018_01a.rs b/2018/src/bin/2018_01a.rs similarity index 97% rename from src/bin/2018_01a.rs rename to 2018/src/bin/2018_01a.rs index e0b4b0f..f7b5b27 100644 --- a/src/bin/2018_01a.rs +++ b/2018/src/bin/2018_01a.rs @@ -2,7 +2,7 @@ // frequency have been applied? use std::collections::HashMap; -use aoc::read_data; +use core::read_data; fn main() { let mut running_total = 0i32; diff --git a/src/bin/2018_01b.rs b/2018/src/bin/2018_01b.rs similarity index 97% rename from src/bin/2018_01b.rs rename to 2018/src/bin/2018_01b.rs index dfb5bae..8ca7ab0 100644 --- a/src/bin/2018_01b.rs +++ b/2018/src/bin/2018_01b.rs @@ -1,7 +1,7 @@ // do part 1a but figure out the first repeated value use std::collections::HashMap; -use aoc::read_data; +use core::read_data; fn main() { let mut visited_locations: HashMap = HashMap::from([(0, 0)]); diff --git a/2019/Cargo.toml b/2019/Cargo.toml new file mode 100644 index 0000000..cac56cc --- /dev/null +++ b/2019/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name="aoc2019" +version = "0.1.0" +edition = "2024" + +[dependencies] +core = { path = "../core" } diff --git a/src/bin/2019_01a.rs b/2019/src/bin/2019_01a.rs similarity index 95% rename from src/bin/2019_01a.rs rename to 2019/src/bin/2019_01a.rs index d0b5a40..164f36c 100644 --- a/src/bin/2019_01a.rs +++ b/2019/src/bin/2019_01a.rs @@ -1,6 +1,6 @@ #![feature(int_roundings)] -use aoc::read_data; +use core::read_data; fn fuel_calc(input: u32) -> u32 { input.div_floor(3).saturating_sub(2) diff --git a/src/bin/2019_01b.rs b/2019/src/bin/2019_01b.rs similarity index 96% rename from src/bin/2019_01b.rs rename to 2019/src/bin/2019_01b.rs index 5aa1f06..31343c2 100644 --- a/src/bin/2019_01b.rs +++ b/2019/src/bin/2019_01b.rs @@ -1,6 +1,6 @@ #![feature(int_roundings)] -use aoc::read_data; +use core::read_data; fn fuel_calc(input: u32) -> u32 { input.div_floor(3).saturating_sub(2) diff --git a/src/bin/2019_02a.rs b/2019/src/bin/2019_02a.rs similarity index 84% rename from src/bin/2019_02a.rs rename to 2019/src/bin/2019_02a.rs index 3e50b77..4a7b36d 100644 --- a/src/bin/2019_02a.rs +++ b/2019/src/bin/2019_02a.rs @@ -1,4 +1,4 @@ -use aoc::read_data; +use core::read_data; fn main() { let directions = read_data("2019_02_data.txt").split(", "); diff --git a/src/bin/2019_04a.rs b/2019/src/bin/2019_04a.rs similarity index 100% rename from src/bin/2019_04a.rs rename to 2019/src/bin/2019_04a.rs diff --git a/src/bin/2019_04a_chatgpt.rs b/2019/src/bin/2019_04a_chatgpt.rs similarity index 100% rename from src/bin/2019_04a_chatgpt.rs rename to 2019/src/bin/2019_04a_chatgpt.rs diff --git a/2020/Cargo.toml b/2020/Cargo.toml new file mode 100644 index 0000000..c1e5493 --- /dev/null +++ b/2020/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name="aoc2020" +version = "0.1.0" +edition = "2024" + +[dependencies] +core = { path = "../core" } diff --git a/src/bin/2020_01a.rs b/2020/src/bin/2020_01a.rs similarity index 95% rename from src/bin/2020_01a.rs rename to 2020/src/bin/2020_01a.rs index aead5a1..ef90306 100644 --- a/src/bin/2020_01a.rs +++ b/2020/src/bin/2020_01a.rs @@ -1,4 +1,4 @@ -use aoc::read_data; +use core::read_data; fn main() { let binding = read_data("2020_01_data.txt"); diff --git a/src/bin/2020_02a.rs b/2020/src/bin/2020_02a.rs similarity index 98% rename from src/bin/2020_02a.rs rename to 2020/src/bin/2020_02a.rs index d51be59..10b6370 100644 --- a/src/bin/2020_02a.rs +++ b/2020/src/bin/2020_02a.rs @@ -1,4 +1,4 @@ -use aoc::read_data; +use core::read_data; #[derive(Clone)] struct ParsedLine { diff --git a/src/bin/2020_02b.rs b/2020/src/bin/2020_02b.rs similarity index 98% rename from src/bin/2020_02b.rs rename to 2020/src/bin/2020_02b.rs index bf4a243..09f0583 100644 --- a/src/bin/2020_02b.rs +++ b/2020/src/bin/2020_02b.rs @@ -1,5 +1,5 @@ use std::io::{stdout, Write}; -use aoc::read_data; +use core::read_data; #[derive(Clone)] struct ParsedLine { diff --git a/2021/Cargo.toml b/2021/Cargo.toml new file mode 100644 index 0000000..37e5eb0 --- /dev/null +++ b/2021/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name="aoc2021" +version = "0.1.0" +edition = "2024" + +[dependencies] +core = { path = "../core" } diff --git a/src/bin/2021_01a.rs b/2021/src/bin/2021_01a.rs similarity index 96% rename from src/bin/2021_01a.rs rename to 2021/src/bin/2021_01a.rs index 80aa68b..2e228c9 100644 --- a/src/bin/2021_01a.rs +++ b/2021/src/bin/2021_01a.rs @@ -1,4 +1,4 @@ -use aoc::read_data; +use core::read_data; fn dips(input: &str) -> u32 { let mut last_reading = 0; diff --git a/src/bin/2021_02a.rs b/2021/src/bin/2021_02a.rs similarity index 97% rename from src/bin/2021_02a.rs rename to 2021/src/bin/2021_02a.rs index 242388b..9818c12 100644 --- a/src/bin/2021_02a.rs +++ b/2021/src/bin/2021_02a.rs @@ -1,4 +1,4 @@ -use aoc::read_data; +use core::read_data; enum CardinalDirection { North, diff --git a/2022/Cargo.toml b/2022/Cargo.toml new file mode 100644 index 0000000..1b64a1e --- /dev/null +++ b/2022/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name="aoc2022" +version = "0.1.0" +edition = "2024" + +[dependencies] +core = { path = "../core" } diff --git a/src/bin/2022_01a.rs b/2022/src/bin/2022_01a.rs similarity index 96% rename from src/bin/2022_01a.rs rename to 2022/src/bin/2022_01a.rs index 6848027..7168aab 100644 --- a/src/bin/2022_01a.rs +++ b/2022/src/bin/2022_01a.rs @@ -1,4 +1,4 @@ -use aoc::read_data; +use core::read_data; fn main() { let binding = read_data("2022_01_data.txt"); diff --git a/src/bin/2022_01b.rs b/2022/src/bin/2022_01b.rs similarity index 98% rename from src/bin/2022_01b.rs rename to 2022/src/bin/2022_01b.rs index 3cafa08..2aaae1f 100644 --- a/src/bin/2022_01b.rs +++ b/2022/src/bin/2022_01b.rs @@ -1,4 +1,4 @@ -use aoc::read_data; +use core::read_data; fn main() { let binding = read_data("2022_01_data.txt"); diff --git a/src/bin/2022_02a.rs b/2022/src/bin/2022_02a.rs similarity index 98% rename from src/bin/2022_02a.rs rename to 2022/src/bin/2022_02a.rs index 3ed05cb..889aa8b 100644 --- a/src/bin/2022_02a.rs +++ b/2022/src/bin/2022_02a.rs @@ -1,4 +1,4 @@ -use aoc::read_data; +use core::read_data; use crate::RPSOutcome::{Loss, Tie, Win}; use crate::RPSPlays::{Paper, Rock, Scissors}; diff --git a/src/bin/2022_02b.rs b/2022/src/bin/2022_02b.rs similarity index 99% rename from src/bin/2022_02b.rs rename to 2022/src/bin/2022_02b.rs index ba524e3..b15fc0a 100644 --- a/src/bin/2022_02b.rs +++ b/2022/src/bin/2022_02b.rs @@ -1,4 +1,4 @@ -use aoc::read_data; +use core::read_data; use crate::RPSOutcome::{Loss, Tie, Win}; use crate::RPSPlays::{Paper, Rock, Scissors}; diff --git a/src/bin/2022_03a.rs b/2022/src/bin/2022_03a.rs similarity index 98% rename from src/bin/2022_03a.rs rename to 2022/src/bin/2022_03a.rs index 1d98de1..d3c33cc 100644 --- a/src/bin/2022_03a.rs +++ b/2022/src/bin/2022_03a.rs @@ -1,6 +1,6 @@ use std::collections::HashSet; use std::io::BufRead; -use aoc::read_data; +use core::read_data; fn char_to_value(input: char) -> u32 { diff --git a/src/bin/2022_03b.rs b/2022/src/bin/2022_03b.rs similarity index 89% rename from src/bin/2022_03b.rs rename to 2022/src/bin/2022_03b.rs index cfcb951..46e1fa4 100644 --- a/src/bin/2022_03b.rs +++ b/2022/src/bin/2022_03b.rs @@ -1,4 +1,4 @@ -use aoc::read_data; +use core::read_data; fn main() { let binding = read_data("2022_03_data.txt"); diff --git a/2023/Cargo.toml b/2023/Cargo.toml new file mode 100644 index 0000000..c6fce26 --- /dev/null +++ b/2023/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name="aoc2023" +version = "0.1.0" +edition = "2024" + +[dependencies] +core = { path = "../core" } diff --git a/src/bin/2023_01a.rs b/2023/src/bin/2023_01a.rs similarity index 98% rename from src/bin/2023_01a.rs rename to 2023/src/bin/2023_01a.rs index d82f344..935d339 100644 --- a/src/bin/2023_01a.rs +++ b/2023/src/bin/2023_01a.rs @@ -1,4 +1,4 @@ -use aoc::read_data; +use core::read_data; fn main() { let mut running_total = 0; diff --git a/2024/Cargo.toml b/2024/Cargo.toml new file mode 100644 index 0000000..3bd236a --- /dev/null +++ b/2024/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name="aoc2024" +version = "0.1.0" +edition = "2024" + +[dependencies] +core = { path = "../core" } diff --git a/src/bin/2024_01a.rs b/2024/src/bin/2024_01a.rs similarity index 100% rename from src/bin/2024_01a.rs rename to 2024/src/bin/2024_01a.rs diff --git a/src/bin/2024_01b.rs b/2024/src/bin/2024_01b.rs similarity index 100% rename from src/bin/2024_01b.rs rename to 2024/src/bin/2024_01b.rs diff --git a/src/bin/2024_02a.rs b/2024/src/bin/2024_02a.rs similarity index 100% rename from src/bin/2024_02a.rs rename to 2024/src/bin/2024_02a.rs diff --git a/Cargo.lock b/Cargo.lock index 2d0ce69..3a1f630 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,12 +3,77 @@ version = 4 [[package]] -name = "aoc" +name = "aoc2015" version = "0.1.0" dependencies = [ + "core", "md-5", ] +[[package]] +name = "aoc2016" +version = "0.1.0" +dependencies = [ + "core", + "md-5", +] + +[[package]] +name = "aoc2017" +version = "0.1.0" +dependencies = [ + "core", +] + +[[package]] +name = "aoc2018" +version = "0.1.0" +dependencies = [ + "core", +] + +[[package]] +name = "aoc2019" +version = "0.1.0" +dependencies = [ + "core", +] + +[[package]] +name = "aoc2020" +version = "0.1.0" +dependencies = [ + "core", +] + +[[package]] +name = "aoc2021" +version = "0.1.0" +dependencies = [ + "core", +] + +[[package]] +name = "aoc2022" +version = "0.1.0" +dependencies = [ + "core", +] + +[[package]] +name = "aoc2023" +version = "0.1.0" +dependencies = [ + "core", +] + +[[package]] +name = "aoc2024" +version = "0.1.0" +dependencies = [ + "core", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -24,6 +89,10 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" +[[package]] +name = "core" +version = "0.1.0" + [[package]] name = "crypto-common" version = "0.1.6" diff --git a/Cargo.toml b/Cargo.toml index 13f5a84..671c8db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,18 @@ -[package] -name="aoc" -version = "0.1.0" -edition = "2024" +[workspace] +members = [ + "core", + "2015", + "2016", + "2017", + "2018", + "2019", + "2020", + "2021", + "2022", + "2023", + "2024" +] +resolver = "2" -[dependencies] -md-5 = "0.10" +[workspace.dependencies] +md-5 = { version = "0.10" } diff --git a/core/Cargo.toml b/core/Cargo.toml new file mode 100644 index 0000000..05a061a --- /dev/null +++ b/core/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "core" +version = "0.1.0" +edition = "2024" \ No newline at end of file diff --git a/src/bin/test.rs b/core/src/bin/test.rs similarity index 100% rename from src/bin/test.rs rename to core/src/bin/test.rs diff --git a/src/lib.rs b/core/src/lib.rs similarity index 92% rename from src/lib.rs rename to core/src/lib.rs index a85c21b..246951e 100644 --- a/src/lib.rs +++ b/core/src/lib.rs @@ -1,10 +1,13 @@ +use std::io::{stdout, Write}; + /// AOC Lib /// Generic methods for loading various data inputs from /// the AOC project. pub fn data_path(suffix: &str) -> String { let path = std::env::var("CARGO_MANIFEST_DIR").unwrap(); - format!("{}/data/{}", path, suffix) + stdout().flush().unwrap(); + format!("{}/../data/{}", path, suffix) } pub fn read_data(suffix: &str) -> String {