BudiBadu Logo
00:00

Mirror Lantern Glow

Recursion Easy 0 views

The Mirror Lantern Walk in Crescent Harbor is a narrow corridor of polished glasswater, lined with caretakers who pace each step to keep the glow steady. Visitors stand at the entrance while a guide taps a bell, calling out how many reflection layers the guardians will sustain that evening. The walkway never changes shape, but every new layer transforms the sensation; watchers see the original lantern, then a mirrored pair, then another ring of flame flaring outward. Your task is to model that ceremonial count so planners can predict how bright the corridor will appear.

The input is a single whole number named layers. When it is zero, only the central lantern shines and the evening ends there. Whenever the caretakers announce a higher layer, they glide in a fresh set of lanterns to frame the current ring, and the entire previous display is doubled across the mirrored panels to keep the rhythm identical on both sides. The keepers repeat this motion level after level, honoring a tradition that grew out of sailors signaling safely home through fog.

Think of the process as a conversation between present and past. A new layer always means a single additional lantern at the leading edge, because the guide must place something tangible before the reflections bloom. After that lantern appears, every lantern you have already counted returns again from both directions, contributing exactly two for each one already present. No shortcuts are allowed; the stewards rely on this precise rule to build the same cascade of light regardless of weather, crowd size, or festival mood.

The value of layers is never negative, and the walkway is compact enough that the total still fits in ordinary counting numbers. Your program should return the final total as an integer representing how many lanterns visitors perceive when the corridor settles. Forget about brightness or timing; only the number of distinct lanterns and their reflections counts. Follow the ritual literally and you will uncover the reliable pattern hidden in the glow.

Example 1:

Input: layers = 0
Output: 1
Explanation: Only the central lantern is visible, so the total count is one.

Example 2:

Input: layers = 2
Output: 7
Explanation: The new layer adds one lantern, and the previous layers contribute twice their earlier total, giving seven perceived lanterns.

Example 3:

Input: layers = 5
Output: 31
Explanation: Five layers mean a fresh lantern plus mirrored echoes of all earlier layers, leading to thirty-one points of light.

Related Problems

No related problems found

Comments (0)

Join the Discussion

Share your thoughts, ask questions, or help others with this problem.

BudiBadu Logo

Mirror Lantern Glow

Recursion Easy 0 views

The Mirror Lantern Walk in Crescent Harbor is a narrow corridor of polished glasswater, lined with caretakers who pace each step to keep the glow steady. Visitors stand at the entrance while a guide taps a bell, calling out how many reflection layers the guardians will sustain that evening. The walkway never changes shape, but every new layer transforms the sensation; watchers see the original lantern, then a mirrored pair, then another ring of flame flaring outward. Your task is to model that ceremonial count so planners can predict how bright the corridor will appear.

The input is a single whole number named layers. When it is zero, only the central lantern shines and the evening ends there. Whenever the caretakers announce a higher layer, they glide in a fresh set of lanterns to frame the current ring, and the entire previous display is doubled across the mirrored panels to keep the rhythm identical on both sides. The keepers repeat this motion level after level, honoring a tradition that grew out of sailors signaling safely home through fog.

Think of the process as a conversation between present and past. A new layer always means a single additional lantern at the leading edge, because the guide must place something tangible before the reflections bloom. After that lantern appears, every lantern you have already counted returns again from both directions, contributing exactly two for each one already present. No shortcuts are allowed; the stewards rely on this precise rule to build the same cascade of light regardless of weather, crowd size, or festival mood.

The value of layers is never negative, and the walkway is compact enough that the total still fits in ordinary counting numbers. Your program should return the final total as an integer representing how many lanterns visitors perceive when the corridor settles. Forget about brightness or timing; only the number of distinct lanterns and their reflections counts. Follow the ritual literally and you will uncover the reliable pattern hidden in the glow.

Example 1:

Input: layers = 0
Output: 1
Explanation: Only the central lantern is visible, so the total count is one.

Example 2:

Input: layers = 2
Output: 7
Explanation: The new layer adds one lantern, and the previous layers contribute twice their earlier total, giving seven perceived lanterns.

Example 3:

Input: layers = 5
Output: 31
Explanation: Five layers mean a fresh lantern plus mirrored echoes of all earlier layers, leading to thirty-one points of light.

00:00
Loading editor...
Test Results

Run your code to see test results

Click the Submit button to execute your solution

Related Problems

No related problems found

Comments (0)

Join the Discussion

Share your thoughts, ask questions, or help others with this problem.