BudiBadu Logo
00:00

Glacier Signal Fires

Recursion Easy 1 views

On the Helio Glacier, guides close each expedition by lighting a chain of signal fires across wind-carved ridges. The ritual begins at dusk with a single spark near base camp. A caller then announces how many ridges will answer that night. Every new ridge must start with one beacon so climbers can fix their bearings, and the ice shelves reflect the glow of the previous ridge three times across the glacier's mirrored walls, weaving a ribbon of light that confirms safe passage back to camp.

The mountaineers treat this pattern as law. As soon as the guiding beacon flares, the ridge releases echoes of the earlier fires from three directions, giving the impression of flames stepping outward in measured intervals. Veterans say the rhythm matters more than speed: constant growth built from the past keeps the team in sync even when the weather howls.

Your task is to determine how many fires are visible when the last ridge settles. The input is a non-negative integer called ridges. When ridges is zero, only base camp glows. For each additional ridge, add one guiding fire and triple the entire blaze from the previous ridge. Return an integer that represents the total number of fires after the sequence completes.

Example 1:

Input: ridges = 0
Output: 1
Explanation: Only the opening signal burns.

Example 2:

Input: ridges = 2
Output: 13
Explanation: The second ridge adds a beacon and repeats the earlier lights three times.

Example 3:

Input: ridges = 4
Output: 121
Explanation: Four responding ridges keep the rule, ending with one guiding fire plus triple the blaze from ridge three.

Related Problems

No related problems found

Comments (0)

Join the Discussion

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

BudiBadu Logo

Glacier Signal Fires

Recursion Easy 1 views

On the Helio Glacier, guides close each expedition by lighting a chain of signal fires across wind-carved ridges. The ritual begins at dusk with a single spark near base camp. A caller then announces how many ridges will answer that night. Every new ridge must start with one beacon so climbers can fix their bearings, and the ice shelves reflect the glow of the previous ridge three times across the glacier's mirrored walls, weaving a ribbon of light that confirms safe passage back to camp.

The mountaineers treat this pattern as law. As soon as the guiding beacon flares, the ridge releases echoes of the earlier fires from three directions, giving the impression of flames stepping outward in measured intervals. Veterans say the rhythm matters more than speed: constant growth built from the past keeps the team in sync even when the weather howls.

Your task is to determine how many fires are visible when the last ridge settles. The input is a non-negative integer called ridges. When ridges is zero, only base camp glows. For each additional ridge, add one guiding fire and triple the entire blaze from the previous ridge. Return an integer that represents the total number of fires after the sequence completes.

Example 1:

Input: ridges = 0
Output: 1
Explanation: Only the opening signal burns.

Example 2:

Input: ridges = 2
Output: 13
Explanation: The second ridge adds a beacon and repeats the earlier lights three times.

Example 3:

Input: ridges = 4
Output: 121
Explanation: Four responding ridges keep the rule, ending with one guiding fire plus triple the blaze from ridge three.

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.