From 755e211f3fa3c895083f5e5bd68af89d66608b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20LUDWIG?= Date: Fri, 8 Dec 2023 18:56:07 +0100 Subject: [PATCH] test: add cases for input.txt --- .editorconfig | 3 +++ .github/workflows/ci.yml | 32 +++++++++++++++++--------------- day_1/README.md | 12 +----------- day_1/src/lib.rs | 10 ++++++++++ day_2/README.md | 10 ---------- day_2/src/lib.rs | 10 ++++++++++ day_3/README.md | 10 ---------- day_3/src/lib.rs | 10 ++++++++++ day_4/README.md | 10 ---------- day_4/src/lib.rs | 10 ++++++++++ 10 files changed, 61 insertions(+), 56 deletions(-) diff --git a/.editorconfig b/.editorconfig index 8d59d07..402bc59 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,3 +9,6 @@ end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true + +[*.{yml,yaml,md}] +indent_size = 2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 869219e..c289be9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,24 +1,26 @@ name: "ci" on: - push: - branches: ["main"] - pull_request: - branches: ["main"] + push: + branches: ["main"] + pull_request: + branches: ["main"] env: - CARGO_TERM_COLOR: "always" + CARGO_TERM_COLOR: "always" jobs: - ci: - runs-on: "ubuntu-latest" + ci: + runs-on: "ubuntu-latest" - steps: - - uses: "actions/checkout@v4" + steps: + - uses: "actions/checkout@v4" + - uses: "dtolnay/rust-toolchain@stable" + with: + components: "clippy, rustfmt" + - run: "rustc --version" - - run: "rustc --version" - - - run: "cargo build --verbose" - - run: "cargo test --verbose" - - run: "cargo clippy --verbose -- -D warnings" - - run: "cargo fmt -- --check" + - run: "cargo build --verbose" + - run: "cargo test --verbose" + - run: "cargo clippy --verbose -- -D warnings" + - run: "cargo fmt -- --check" diff --git a/day_1/README.md b/day_1/README.md index ffde724..2fa1725 100644 --- a/day_1/README.md +++ b/day_1/README.md @@ -27,13 +27,7 @@ treb7uchet In this example, the calibration values of these four lines are `12`, `38`, `15`, and `77`. Adding these together produces `142`. -Consider your entire calibration document. What is the sum of all of the calibration values? - -To begin, [get your puzzle input](./input.txt). - -Your puzzle answer was `55130`. - -**The first half of this puzzle is complete! It provides one gold star: `*`.** +Consider your entire calibration document. **What is the sum of all of the calibration values?** ## Instructions - Part 2 @@ -54,7 +48,3 @@ zoneight234 In this example, the calibration values are `29`, `83`, `13`, `24`, `42`, `14`, and `76`. Adding these together produces `281`. **What is the sum of all of the calibration values?** - -Your puzzle answer was `54985`. - -**Both parts of this puzzle are complete! They provide two gold stars: `**`.** diff --git a/day_1/src/lib.rs b/day_1/src/lib.rs index 89c029e..2ce941b 100644 --- a/day_1/src/lib.rs +++ b/day_1/src/lib.rs @@ -76,4 +76,14 @@ mod day_1_tests { fn test_part_2_example() { assert_eq!(part_2(include_str!("../input_example_2.txt")), 281); } + + #[test] + fn test_part_1() { + assert_eq!(part_1(include_str!("../input.txt")), 55130); + } + + #[test] + fn test_part_2() { + assert_eq!(part_2(include_str!("../input.txt")), 54985); + } } diff --git a/day_2/README.md b/day_2/README.md index 7ce5cc2..3a808ac 100644 --- a/day_2/README.md +++ b/day_2/README.md @@ -32,12 +32,6 @@ In the example above, games 1, 2, and 5 would have been **possible** if the bag Determine which games would have been possible if the bag had been loaded with only 12 red cubes, 13 green cubes, and 14 blue cubes. **What is the sum of the IDs of those games?** -To begin, [get your puzzle input](./input.txt). - -Your puzzle answer was `2617`. - -**The first half of this puzzle is complete! It provides one gold star: `*`.** - ## Instructions - Part 2 The Elf says they've stopped producing snow because they aren't getting any **water**! He isn't sure why the water stopped; however, he can show you how to get to the water source to check it out for yourself. It's just up ahead! @@ -63,7 +57,3 @@ Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green The **power** of a set of cubes is equal to the numbers of red, green, and blue cubes multiplied together. The power of the minimum set of cubes in game 1 is `48`. In games 2-5 it was `12`, `1560`, `630`, and `36`, respectively. Adding up these five powers produces the sum **`2286`**. For each game, find the minimum set of cubes that must have been present. **What is the sum of the power of these sets?** - -Your puzzle answer was `59795`. - -**Both parts of this puzzle are complete! They provide two gold stars: `**`.** diff --git a/day_2/src/lib.rs b/day_2/src/lib.rs index 44ab69d..b93cbf1 100644 --- a/day_2/src/lib.rs +++ b/day_2/src/lib.rs @@ -185,4 +185,14 @@ mod day_2_tests { fn test_part_2_example() { assert_eq!(part_2(include_str!("../input_example_1.txt")), 2286); } + + #[test] + fn test_part_1() { + assert_eq!(part_1(include_str!("../input.txt")), 2617); + } + + #[test] + fn test_part_2() { + assert_eq!(part_2(include_str!("../input.txt")), 59795); + } } diff --git a/day_3/README.md b/day_3/README.md index 990527e..3beca4e 100644 --- a/day_3/README.md +++ b/day_3/README.md @@ -35,12 +35,6 @@ In this schematic, two numbers are **not** part numbers because they are not adj Of course, the actual engine schematic is much larger. **What is the sum of all of the part numbers in the engine schematic?** -To begin, [get your puzzle input](./input.txt). - -Your puzzle answer was `553079`. - -**The first half of this puzzle is complete! It provides one gold star: `*`.** - ## Instructions - Part 2 The engineer finds the missing part and installs it in the engine! As the engine springs to life, you jump in the closest gondola, finally ready to ascend to the water source. @@ -71,7 +65,3 @@ Consider the same engine schematic again: In this schematic, there are **two** gears. The first is in the top left; it has part numbers `467` and `35`, so its gear ratio is `16345`. The second gear is in the lower right; its gear ratio is `451490`. (The `*` adjacent to `617` is **not** a gear because it is only adjacent to one part number.) Adding up all of the gear ratios produces **`467835`**. **What is the sum of all of the gear ratios in your engine schematic?** - -Your puzzle answer was `84363105`. - -**Both parts of this puzzle are complete! They provide two gold stars: `**`.** diff --git a/day_3/src/lib.rs b/day_3/src/lib.rs index ca3730b..6232336 100644 --- a/day_3/src/lib.rs +++ b/day_3/src/lib.rs @@ -213,4 +213,14 @@ mod day_3_tests { fn test_part_2_example() { assert_eq!(part_2(include_str!("../input_example_1.txt")), 467835); } + + #[test] + fn test_part_1() { + assert_eq!(part_1(include_str!("../input.txt")), 553079); + } + + #[test] + fn test_part_2() { + assert_eq!(part_2(include_str!("../input.txt")), 84363105); + } } diff --git a/day_4/README.md b/day_4/README.md index 7d00eb6..5f88b14 100644 --- a/day_4/README.md +++ b/day_4/README.md @@ -41,12 +41,6 @@ So, in this example, the Elf's pile of scratchcards is worth **`13`** points. Take a seat in the large pile of colorful cards. **How many points are they worth in total?** -To begin, [get your puzzle input](./input.txt). - -Your puzzle answer was `24160`. - -**The first half of this puzzle is complete! It provides one gold star: `*`.** - ## Instructions - Part 2 Just as you're about to report your findings to the Elf, one of you realizes that the rules have actually been printed on the back of every card this whole time. @@ -79,7 +73,3 @@ Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11 Once all of the originals and copies have been processed, you end up with 1 instance of card 1, **`2`** instances of card 2, **`4`** instances of card 3, **`8`** instances of card 4, **`14`** instances of card 5, and **`1`** instance of card 6. In total, this example pile of scratchcards causes you to ultimately have **`30`** scratchcards! Process all of the original and copied scratchcards until no more scratchcards are won. Including the original set of scratchcards, **how many total scratchcards do you end up with**? - -Your puzzle answer was `5659035`. - -**Both parts of this puzzle are complete! They provide two gold stars: `**`.** diff --git a/day_4/src/lib.rs b/day_4/src/lib.rs index f88cde0..a7b87fd 100644 --- a/day_4/src/lib.rs +++ b/day_4/src/lib.rs @@ -160,4 +160,14 @@ mod day_4_tests { fn test_part_2_example() { assert_eq!(part_2(include_str!("../input_example_1.txt")), 30); } + + #[test] + fn test_part_1() { + assert_eq!(part_1(include_str!("../input.txt")), 24160); + } + + #[test] + fn test_part_2() { + assert_eq!(part_2(include_str!("../input.txt")), 5659035); + } }