From b55df3d44850e6d160e24327cac1551508901d49 Mon Sep 17 00:00:00 2001 From: Fabian Schmidt Date: Wed, 30 Oct 2024 11:34:40 +0100 Subject: [PATCH] Renamed tests --- y2015/resources/14_input.txt | 9 +++++++++ y2015/src/bin/d14.rs | 20 +++++++++++++++++++ y2015/src/days/d1.rs | 4 ++-- y2015/src/days/d10.rs | 4 ++-- y2015/src/days/d12.rs | 4 ++-- y2015/src/days/d13.rs | 4 ++-- y2015/src/days/d14.rs | 37 ++++++++++++++++++++++++++++++++++++ y2015/src/days/d2.rs | 4 ++-- y2015/src/days/d3.rs | 4 ++-- y2015/src/days/d4.rs | 4 ++-- y2015/src/days/d5.rs | 4 ++-- y2015/src/days/d6.rs | 4 ++-- y2015/src/days/d7.rs | 4 ++-- y2015/src/days/d8.rs | 4 ++-- y2015/src/days/d9.rs | 4 ++-- y2015/src/days/mod.rs | 1 + y2022/src/days/d1.rs | 2 +- y2022/src/days/d2.rs | 2 +- 18 files changed, 93 insertions(+), 26 deletions(-) create mode 100644 y2015/resources/14_input.txt create mode 100644 y2015/src/bin/d14.rs create mode 100644 y2015/src/days/d14.rs diff --git a/y2015/resources/14_input.txt b/y2015/resources/14_input.txt new file mode 100644 index 0000000..2af1170 --- /dev/null +++ b/y2015/resources/14_input.txt @@ -0,0 +1,9 @@ +Vixen can fly 19 km/s for 7 seconds, but then must rest for 124 seconds. +Rudolph can fly 3 km/s for 15 seconds, but then must rest for 28 seconds. +Donner can fly 19 km/s for 9 seconds, but then must rest for 164 seconds. +Blitzen can fly 19 km/s for 9 seconds, but then must rest for 158 seconds. +Comet can fly 13 km/s for 7 seconds, but then must rest for 82 seconds. +Cupid can fly 25 km/s for 6 seconds, but then must rest for 145 seconds. +Dasher can fly 14 km/s for 3 seconds, but then must rest for 38 seconds. +Dancer can fly 3 km/s for 16 seconds, but then must rest for 37 seconds. +Prancer can fly 25 km/s for 6 seconds, but then must rest for 143 seconds. diff --git a/y2015/src/bin/d14.rs b/y2015/src/bin/d14.rs new file mode 100644 index 0000000..a520e1d --- /dev/null +++ b/y2015/src/bin/d14.rs @@ -0,0 +1,20 @@ +use std::fs; + +use y2015::days::d14; + +fn main() { + part1(); + part2(); +} + +fn part1() { + let root = env!("CARGO_MANIFEST_DIR"); + let content = fs::read_to_string(format!("{root}/resources/14_input.txt")).unwrap(); + println!("{}", d14::process_part1(&content)); +} + +fn part2() { + let root = env!("CARGO_MANIFEST_DIR"); + let content = fs::read_to_string(format!("{root}/resources/14_input.txt")).unwrap(); + println!("{}", d14::process_part2(&content)); +} diff --git a/y2015/src/days/d1.rs b/y2015/src/days/d1.rs index 28d6afe..2f6ba1d 100644 --- a/y2015/src/days/d1.rs +++ b/y2015/src/days/d1.rs @@ -39,11 +39,11 @@ pub fn process_part2(input: &str) -> i32 { } #[cfg(test)] -mod tests_1 { +mod tests { use super::*; #[test] - fn it_works() { + fn part1() { let result = process_part1("(())"); assert_eq!(result, 0); let result = process_part1("(())"); diff --git a/y2015/src/days/d10.rs b/y2015/src/days/d10.rs index 876ed5a..7554695 100644 --- a/y2015/src/days/d10.rs +++ b/y2015/src/days/d10.rs @@ -38,11 +38,11 @@ fn look_and_say(number: &str) -> String { } #[cfg(test)] -mod tests_10 { +mod tests { use super::*; #[test] - fn it_works() { + fn part1() { let result = look_and_say("1"); assert_eq!(result, "11".to_string()); let result = look_and_say("11"); diff --git a/y2015/src/days/d12.rs b/y2015/src/days/d12.rs index 82f9b3c..dd89efb 100644 --- a/y2015/src/days/d12.rs +++ b/y2015/src/days/d12.rs @@ -126,11 +126,11 @@ fn find_close(string: &str) -> u32 { } #[cfg(test)] -mod tests_12 { +mod tests { use super::*; #[test] - fn it_works() { + fn part1() { let result_a = process_part1("[1,2,3]"); let result_b = process_part1(r#"{"a":2,"b":4}"#); assert_eq!(result_a, 6); diff --git a/y2015/src/days/d13.rs b/y2015/src/days/d13.rs index bbb7a93..adb2b7f 100644 --- a/y2015/src/days/d13.rs +++ b/y2015/src/days/d13.rs @@ -159,7 +159,7 @@ pub fn process_part2(input: &str) -> i32 { } #[cfg(test)] -mod tests_13 { +mod tests { use super::*; const INPUT: &str = "Alice would gain 54 happiness units by sitting next to Bob. @@ -176,7 +176,7 @@ David would lose 7 happiness units by sitting next to Bob. David would gain 41 happiness units by sitting next to Carol."; #[test] - fn it_works() { + fn part1() { let result = process_part1(INPUT); assert_eq!(result, 330); } diff --git a/y2015/src/days/d14.rs b/y2015/src/days/d14.rs new file mode 100644 index 0000000..c8b578a --- /dev/null +++ b/y2015/src/days/d14.rs @@ -0,0 +1,37 @@ +pub fn process_part1(input: &str) -> i32 { + 0 +} + +pub fn process_part2(input: &str) -> i32 { + 0 +} + +#[cfg(test)] +mod tests { + use super::*; + + const INPUT: &str = "Alice would gain 54 happiness units by sitting next to Bob. +Alice would lose 79 happiness units by sitting next to Carol. +Alice would lose 2 happiness units by sitting next to David. +Bob would gain 83 happiness units by sitting next to Alice. +Bob would lose 7 happiness units by sitting next to Carol. +Bob would lose 63 happiness units by sitting next to David. +Carol would lose 62 happiness units by sitting next to Alice. +Carol would gain 60 happiness units by sitting next to Bob. +Carol would gain 55 happiness units by sitting next to David. +David would gain 46 happiness units by sitting next to Alice. +David would lose 7 happiness units by sitting next to Bob. +David would gain 41 happiness units by sitting next to Carol."; + + #[test] + fn part1() { + let result = process_part1(INPUT); + assert_eq!(result, 330); + } + + #[test] + fn part2() { + let result = process_part2(INPUT); + assert_eq!(result, 0); + } +} diff --git a/y2015/src/days/d2.rs b/y2015/src/days/d2.rs index 5399dd2..b85b046 100644 --- a/y2015/src/days/d2.rs +++ b/y2015/src/days/d2.rs @@ -37,14 +37,14 @@ pub fn process_part2(input: &str) -> i64 { } #[cfg(test)] -mod tests_2 { +mod tests { use super::*; const INPUT: &str = "2x3x4 1x1x10"; #[test] - fn it_works() { + fn part1() { let result = process_part1(INPUT); assert_eq!(result, 101); } diff --git a/y2015/src/days/d3.rs b/y2015/src/days/d3.rs index 46f1efe..6788249 100644 --- a/y2015/src/days/d3.rs +++ b/y2015/src/days/d3.rs @@ -75,7 +75,7 @@ pub fn process_part2(input: &str) -> i64 { } #[cfg(test)] -mod tests_3 { +mod tests { use super::*; const INPUT: &str = "> @@ -84,7 +84,7 @@ mod tests_3 { ^v^v^v^v^v"; #[test] - fn it_works() { + fn part1() { let mut lines = INPUT.lines(); let result = process_part1(lines.next().unwrap()); assert_eq!(result, 2); diff --git a/y2015/src/days/d4.rs b/y2015/src/days/d4.rs index 19035c8..e6db53e 100644 --- a/y2015/src/days/d4.rs +++ b/y2015/src/days/d4.rs @@ -56,14 +56,14 @@ pub fn process_part2(input: &str) -> i64 { } #[cfg(test)] -mod tests_4 { +mod tests { use super::*; const INPUT1: &str = "abcdef"; const INPUT2: &str = "pqrstuv"; #[test] - fn it_works() { + fn part1() { let result = process_part1(INPUT1); assert_eq!(result, 609043); let result = process_part1(INPUT2); diff --git a/y2015/src/days/d5.rs b/y2015/src/days/d5.rs index 4c44047..4e85cbf 100644 --- a/y2015/src/days/d5.rs +++ b/y2015/src/days/d5.rs @@ -76,7 +76,7 @@ pub fn process_part2(input: &str) -> i32 { } #[cfg(test)] -mod tests_5 { +mod tests { use super::*; const INPUT1: &str = "ugknbfddgicrmopn @@ -86,7 +86,7 @@ haegwjzuvuyypxyu dvszwmarrgswjxmb"; #[test] - fn it_works() { + fn part1() { let result = process_part1(INPUT1); assert_eq!(result, 2); } diff --git a/y2015/src/days/d6.rs b/y2015/src/days/d6.rs index 2b9d8cb..13c2c90 100644 --- a/y2015/src/days/d6.rs +++ b/y2015/src/days/d6.rs @@ -98,7 +98,7 @@ pub fn process_part2(input: &str) -> u32 { } #[cfg(test)] -mod tests_6 { +mod tests { use super::*; const INPUT1: &str = "turn on 0,0 through 999,999"; @@ -106,7 +106,7 @@ mod tests_6 { const INPUT3: &str = "turn off 499,499 through 500,500"; #[test] - fn it_works() { + fn part1() { let result = process_part1(INPUT1); assert_eq!(result, 1_000_000); let result = process_part1(format!("{INPUT1}\n{INPUT2}").as_str()); diff --git a/y2015/src/days/d7.rs b/y2015/src/days/d7.rs index 9ddc88a..5c0c243 100644 --- a/y2015/src/days/d7.rs +++ b/y2015/src/days/d7.rs @@ -101,7 +101,7 @@ pub fn process_part2(input: &str) -> HashMap { } #[cfg(test)] -mod tests_7 { +mod tests { use super::*; const INPUT: &str = "123 -> x @@ -114,7 +114,7 @@ NOT y -> i 456 -> y"; #[test] - fn it_works() { + fn part1() { let mut expected = HashMap::new(); expected.insert("d".to_string(), 72); expected.insert("e".to_string(), 507); diff --git a/y2015/src/days/d8.rs b/y2015/src/days/d8.rs index 9a20cc6..0834143 100644 --- a/y2015/src/days/d8.rs +++ b/y2015/src/days/d8.rs @@ -41,7 +41,7 @@ pub fn process_part2(input: &str) -> u32 { } #[cfg(test)] -mod tests_8 { +mod tests { use super::*; const INPUT: &str = r#""" @@ -51,7 +51,7 @@ mod tests_8 { "#; #[test] - fn it_works() { + fn part1() { let result = process_part1(INPUT); assert_eq!(result, 12); } diff --git a/y2015/src/days/d9.rs b/y2015/src/days/d9.rs index 98e7663..c3319f4 100644 --- a/y2015/src/days/d9.rs +++ b/y2015/src/days/d9.rs @@ -104,7 +104,7 @@ pub fn process_part2(input: &str) -> u32 { } #[cfg(test)] -mod tests_9 { +mod tests { use super::*; const INPUT: &str = "London to Dublin = 464 @@ -112,7 +112,7 @@ London to Belfast = 518 Dublin to Belfast = 141"; #[test] - fn it_works() { + fn part1() { let result = process_part1(INPUT); assert_eq!(result, 605); } diff --git a/y2015/src/days/mod.rs b/y2015/src/days/mod.rs index dda6b70..14333e1 100644 --- a/y2015/src/days/mod.rs +++ b/y2015/src/days/mod.rs @@ -3,6 +3,7 @@ pub mod d10; pub mod d11; pub mod d12; pub mod d13; +pub mod d14; pub mod d2; pub mod d3; pub mod d4; diff --git a/y2022/src/days/d1.rs b/y2022/src/days/d1.rs index 3874d3e..6d2330d 100644 --- a/y2022/src/days/d1.rs +++ b/y2022/src/days/d1.rs @@ -36,7 +36,7 @@ mod tests { 10000"; #[test] - fn it_works() { + fn part1() { let result = process_part1(INPUT); assert_eq!(result, 24000); } diff --git a/y2022/src/days/d2.rs b/y2022/src/days/d2.rs index e92a935..35c9a84 100644 --- a/y2022/src/days/d2.rs +++ b/y2022/src/days/d2.rs @@ -93,7 +93,7 @@ B X C Z"; #[test] - fn it_works() { + fn part1() { let result = process_part1(INPUT); assert_eq!(result, 15); }