Introduction
You’re a researcher at PRISM (Precariously Redirected Illumination Safety Management), working with a precision laser calibration system that tests experimental crystal prisms. These crystals are being developed for next-generation optical computers, and each one has unique refractive properties based on its molecular structure. The lab’s laser system can damage crystals if they receive unexpected illumination, so precise path prediction is critical.
Your Task
Before activating the laser array, you must predict:
- Total crystals illuminated: How many crystal samples will be exposed to the laser beam
- Illumination sequence: The exact order in which crystals will be hit, identified by their sample IDs
Example Test Case
Consider this crystal array configuration:
{
"input": {
"start": { "x": 0, "y": 0, "angle": 0 },
"prisms": [
{ "id": 1, "x": 10, "y": 0, "angle": 90 },
{ "id": 2, "x": 20, "y": 0, "angle": 0 },
{ "id": 3, "x": 10, "y": 10, "angle": -90 },
{ "id": 4, "x": 30, "y": 10, "angle": 45 }
]
},
"expected": {
"total": 3,
"sequence": [1, 3, 4]
}
}
What’s Happening
The laser starts at the origin (0, 0) and fires horizontally to the right at angle 0°. Here’s the step-by-step beam path:
Step 1: The beam travels along the x-axis (y = 0) and first encounters Crystal #1 at position (10, 0). This crystal has a refraction angle of 90°, which means it bends the beam perpendicular to its current path. The beam, originally traveling at 0°, is now redirected to 90° (straight up).
Step 2: The beam now travels vertically upward from position (10, 0) and strikes Crystal #3 at position (10, 10). This crystal has a refraction angle of -90°, bending the beam by -90° relative to its current direction. The beam was traveling at 90°, so after refraction it’s now at 0° (90° + (-90°) = 0°), traveling horizontally to the right again.
Step 3: From position (10, 10), the beam travels horizontally and encounters Crystal #4 at position (30, 10). This crystal refracts the beam by 45°, changing its direction to 45°. The beam continues into empty space beyond the array.
The only addition I would make would be to also take into account the total number of prisms affected, as one of them could be illuminated more than once.
Perhaps instead of the total, I would put a list of frequencies, but even as it is, I don’t mind it at all.