solve 18-12-2025

This commit is contained in:
YannAhlgrim
2025-12-18 18:15:08 +01:00
parent 4d92204920
commit 606d206dd1
4 changed files with 4717 additions and 2 deletions
+4664
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+33
View File
@@ -0,0 +1,33 @@
use std::fs;
fn main() {
let mut pointer = 50;
let mut zero_count = 0;
let input: String = fs::read_to_string("input.txt").expect("text file cannot be read to string");
let input = input.split("\n");
// let input = ["L68", "L30", "R48", "L5", "R60", "L55", "L1", "L99", "R14", "L82"];
for element in input {
if element == "" {
break;
}
let steps: i32 = (&element[1..]).parse().unwrap();
if element.contains("L") {
pointer -= steps;
} else {
pointer += steps;
}
pointer = pointer % 100;
if pointer < 0 {
pointer += 100;
}
println!("The dial is rotated {element} to point at {pointer}");
if pointer == 0 {
zero_count += 1;
}
}
println!("Number of Zeros: {zero_count}");
}
+20 -2
View File
@@ -1,6 +1,5 @@
--- Day 1: Secret Entrance ---
# Day 1: Secret Entrance
The Elves have good news and bad news.
The good news is that they've discovered project management! This has given them the tools they need to prevent their usual Christmas emergency. For example, they now know that the North Pole decorations need to be finished soon so that other critical tasks can start on time.
@@ -41,3 +40,22 @@ L1
L99
R14
L82
Following these rotations would cause the dial to move as follows:
- The dial starts by pointing at 50.
- The dial is rotated L68 to point at 82.
- The dial is rotated L30 to point at 52.
- The dial is rotated R48 to point at 0.
- The dial is rotated L5 to point at 95.
- The dial is rotated R60 to point at 55.
- The dial is rotated L55 to point at 0.
- The dial is rotated L1 to point at 99.
- The dial is rotated L99 to point at 0.
- The dial is rotated R14 to point at 14.
- The dial is rotated L82 to point at 32.
Because the dial points at 0 a total of three times during this process, the password in this example is 3.
Analyze the rotations in your attached document. What's the actual password to open the door?