BudiBadu Logo
00:00

River Brightening Signal

Recursion Easy 0 views

During the spring thaw, Riverspan settlements coordinate with a nightly signal relay. The first beacon ignites near the upstream dock, lighting the current for returning barges. The relay master announces how many downstream outposts will answer the signal. Each outpost sets one fresh lantern on the bank, and the watchers from the previous post mirror their light twice, sending twin reflections across the water to reassure crews navigating the bends.

Villagers trust this cadence to keep shipments safe even when currents surge. Once the guiding lantern burns, the relay ensures every earlier light reappears along both banks, merging into rhythmic flashes that help boats align their moorings. Nobody alters the sequence; the rule of one beacon plus two echoes grounds the nightly routine.

Your task is to count how many lanterns glow before the relay ends. The input, stations, is a non-negative integer. When stations equals zero, only the upstream beacon shines. For each additional station, add one guiding lantern and double the entire relay from the prior station. Return the total number of lights as an integer.

Example 1:

Input: stations = 0
Output: 1
Explanation: Only the first beacon is lit.

Example 2:

Input: stations = 2
Output: 7
Explanation: The second station adds a lantern and mirrors the earlier lights twice.

Example 3:

Input: stations = 4
Output: 31
Explanation: Four stations maintain the rule, producing thirty-one bright signals.

Related Problems

No related problems found

Comments (0)

Join the Discussion

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

BudiBadu Logo

River Brightening Signal

Recursion Easy 0 views

During the spring thaw, Riverspan settlements coordinate with a nightly signal relay. The first beacon ignites near the upstream dock, lighting the current for returning barges. The relay master announces how many downstream outposts will answer the signal. Each outpost sets one fresh lantern on the bank, and the watchers from the previous post mirror their light twice, sending twin reflections across the water to reassure crews navigating the bends.

Villagers trust this cadence to keep shipments safe even when currents surge. Once the guiding lantern burns, the relay ensures every earlier light reappears along both banks, merging into rhythmic flashes that help boats align their moorings. Nobody alters the sequence; the rule of one beacon plus two echoes grounds the nightly routine.

Your task is to count how many lanterns glow before the relay ends. The input, stations, is a non-negative integer. When stations equals zero, only the upstream beacon shines. For each additional station, add one guiding lantern and double the entire relay from the prior station. Return the total number of lights as an integer.

Example 1:

Input: stations = 0
Output: 1
Explanation: Only the first beacon is lit.

Example 2:

Input: stations = 2
Output: 7
Explanation: The second station adds a lantern and mirrors the earlier lights twice.

Example 3:

Input: stations = 4
Output: 31
Explanation: Four stations maintain the rule, producing thirty-one bright signals.

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.