In this puzzle, we're tasked with simulating the behavior of a beam of light as it moves through a contraption in a cave. The contraption is a grid containing mirrors (/
and \
), splitters (|
and -
), and empty space (.
). The beam of light enters the grid from the top-left corner and moves according to these rules:
- Continues in the same direction in empty space (
.
). - Reflects 90 degrees when hitting a mirror (
/
or\
). - Passes through the pointy end of a splitter (
|
or-
) as if it were empty space. - Splits into two beams at the flat side of a splitter (
|
or-
), with each new beam going in the directions the splitter's pointy ends point.