AoC - Day 1b
December 8, 2025 •2 min read
Secret Entrance
Part 2
The puzzle answer to Part 1 gave 1034.
You're sure that's the right password, but the door won't open. You knock, but nobody answers. You build a snowman while you think.
As you're rolling the snowballs for your snowman, you find another security document that must have fallen into the snow:
"Due to newer security protocols, please use password method 0x434C49434B until further notice."
You remember from the training seminar that "method 0x434C49434B" means you're actually supposed to count the number of times any click causes the dial to point at 0, regardless of whether it happens during a rotation or at the end of one.
Using password method 0x434C49434B, what is the password to open the door?
Solution
const fileContent = require("fs").readFileSync(
require("path").join(process.cwd(), "day1.txt"),
"utf8"
);
const lines = fileContent.split("\n");
let count = 0;
const DIAL_LENGTH = 100;
lines.reduce((counter, line) => {
const direction = line.at(0);
const steps = parseInt(line.slice(1));
if (direction === "R") {
const dial = counter + steps;
count += Math.floor(dial / DIAL_LENGTH);
return dial % DIAL_LENGTH;
} else {
const dial = counter - steps;
const diff = steps % DIAL_LENGTH;
const remainder = counter - diff;
!!counter && remainder <= 0 && count++;
count += Math.abs(Math.trunc((steps - diff) / DIAL_LENGTH));
return Math.abs(((dial % DIAL_LENGTH) + DIAL_LENGTH) % DIAL_LENGTH);
}
}, 50);