Advent of Code

LyricLy 20*

   var y=2025;

--- Day 11: Ghostly Ghorridoors ---

As the dust settles, you find yourself in a dark room. The air is hazy and dusty, so you can't quite make out your surroundings. You're still disoriented from tumbling down the spiral stairs, and can barely tell left from right.

As you try to gather your senses, hear something spooky. Are those ghosts? Oh no. Maybe you shouldn't have drank that pumpkin juice...

"I think we fell into the storage closet," your elf companion remarks suddenly, interrupting your thoughts. She tugs on your chain slightly.

"I used to go here during my lunch breaks to eat donuts in peace. It's pretty easy to get lost, though, so I always brought a map with me."

She takes a curious look around. "I wonder if I still have my map, hmm..."

With some shuffling, she sits down and takes off her left boot. The iron chain shackling you two together clinks a little as she pulls off her festive woolen sock. You instinctively scrunch up your nose at the scent wafting from her bare sweaty foot.

"Aha! I knew it was here somewhere!" she exclaims, revealing a folded up, slightly moist piece of paper. "I never lose my maps," she gloats.

You unfold the giant map on the ground. The map has seen some better days, but you can still make it out somewhat. From inspection, it seems that this place is full of diagonal mirrors, intersections, and strange empty spaces.

"Oh, those are ghost spaces. You probably don't want to walk into one," she helpfully points out. "They're not dangerous or anything. But it's pretty hard to leave them." You figure that you'll want to find a way through here to the exit without going through a ghost tile.

"They are very talkative and can chatter on for hours," she continues. "But they can be a bit... gloomy. I don't really like their dark humor." You can't see so well in the darkness, but her outfit is a gleeful mixture of the seven primary colors.

You check your pocket and notice that you still have your flashlight with you. You pull it out and flick the switch on and off. The flashlight is battered from the game you played with the rock gnomes, but it still functions. However, its light flickers noticeably. You fear the battery will run out any second.

You inspect the map closer, this time with the help of light. You can make out three different types of squares:

+ is an intersection square. It lets you and your flashlight pass through along the horizontal and vertical axes. Strangely, it won't let you turn around in angles; you can only traverse between east and west, or between north and south independently.

\ and / mirror squares. Any light that enters will be reflected across the diagonal. The mirrors also reach up to the ceiling, which means you can only walk the same path as the light.

is a ghost space. "Isn't that supposed to be a .?" you wonder out loud. "No," your friend replies confidently. Whenever your beam of light enters a ghost space, it gets eaten up and disappears. Furthermore, if you step into this square, you'll be forced to listen to the ghosts and their jokes.

Here's an example of what a map looks like:

  /+/ \/

To start off, you're going to perform a sanity check and see whether it's even possible to reach the exit from whereever you are. To do this, count the number of paths that go through the entire map (without going through a ghost space) from east to west, or from north to south.

In the example above, there's two paths through the map:

  /#/ \/
  /+/ \/

Count the paths that pass through the whole map, for each of the maps in your input. What is the sum of these counts?

To begin, get your puzzle input.


You can also this puzzle.