Mirror Lantern Glow
In Crescent Harbor, caretakers sustain a corridor of glasswater with reflection layers. Each layer transforms the sensation of the central lantern into a flaring ring of light. Your task in Mirror Lantern Glow is to model the ceremonial count of perceived lanterns as the reflection layers deepen. Planners use this to predict exactly how bright the walkway will appear to visitors.
The "secret sauce" here is a Doubling Reflection Pattern. For every new layer, you add one new tangible lantern, and then every existing lantern (and its reflection) is doubled across the mirrored panels. If layers is zero, only the central lantern shines (result: 1). This recursive doubling captures the symmetrical bloom of light that signaled sailors home through the fog. Return the final count as a single integer, ensuring the stewards can build the same cascade of light every festival night! Precision helps maintain the history and mood of the Crescent Harbor tradition beautifully.
Keep the algorithm focused on one clear invariant and update path so correctness is easy to verify from left to right. This reduces accidental branching errors and helps ensure the final output stays consistent with the problem contract across random and adversarial test shapes.
Examples
The new layer adds one lantern, and the previous layers contribute twice their earlier total, giving seven perceived lanterns.
Only the central lantern is visible, so the total count is one.
Five layers mean a fresh lantern plus mirrored echoes of all earlier layers, leading to thirty-one points of light.
Algorithm Flow

Best Answers
class Solution {
public int mirror_lantern_glow(Object input) {
int layers = (int) input;
return (int) Math.pow(2, layers + 1) - 1;
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this problem.
