The last and final day of Advent of Code is here! What a great ride! I’ll share my thoughts of this experience in a subsequent post soon.
Day 25: Combo Breaker
Part I
Working with a security key card, and some sniffing on what’s going on between the key card and to door, I have to hack the door. There is no large input file, instead it’s just a public key from the card and from the door.
const card = 15628416
let cardloopSize = 0
let answer = 1
while(answer !== card) {
answer = answer * 7
answer = answer % 20201227
cardloopSize += 1
}
console.log(cardloopSize, 'card loopsize')
The card
is the input from the puzzle, and represents the card’s public key. We then loop, multiplying the answer
by 7 and then getting the remainder from 20201227
and setting it to answer
. Once it matches, we have our loop size.
const door = 11161639
let doorloopSize = 0
answer = 1
while(answer !== door) {
answer = answer * 7
answer = answer % 20201227
doorloopSize += 1
}
console.log(doorloopSize, 'door loopsize')
We then do the same thing to get the doorLoopSize
let encryption = 1
for(let i = 0; i < cardloopSize; i ++){
encryption = encryption * door
encryption = encryption % 20201227
}
console.log(encryption, 'encryption')
Then, using either loop size, we can process the encryption key using the other items public key. I chose to use the cardLoopSize
and loop the door
‘s public key. encryption
is our answer!
SPOILERS
If you haven’t completed day 25, stop scrolling, and see the final part on your own!
It’s a great surprise
A Christmas gift for you
But okay
Here it is
Are you sure?
Ok fine
Here…
Part II
There was none! It was a Christmas miracle. Actually, to solve part 2, I needed 49 stars, all stars from all of the other puzzles. If you’ve been following along, you’ll notice I skipped a day or two. I had to go back and work on those to get my 49 stars, then finally:

and my advent calendar is so pretty now!

Merry Christmas!
How did it go for you?
How did you find the answer on your own? How did you do it? Anything stump you? I’d love to hear how you did! Please comment below! I have also loaded up just the challenge and code from this and my other days on github, you can follow along there too: pretty Git pages or the code in the repo.
Leave a Reply