BudiBadu Logo
00:00

Festival Drum Echoes

Recursion Easy 0 views

The Riverlight Drum Festival arrives with nightfall, when lanterns float above the river and the first drummer strikes a single resonant beat. The crowd falls silent as that note rolls across the water. Organizers describe each level of the celebration as a new circle of performers who wait for their cue, listening to how the earlier level responds, and then mirroring that momentum to keep the rhythm alive.

A whole number called levels controls how many layers follow the opening strike. Level zero represents only the first beat. For any higher level, the lead drummer introduces one new beat, and every beat from the previous level is answered twice to keep the echo alive beneath the cliffs. Listeners say the sound feels like thunder weaving through stone corridors, yet the pattern stays consistent no matter how many circles join in.

Your task is to report how many beats the audience hears by the end of the performance. The value of levels is never negative, and you do not skip levels. Each level expands the sound in the same dependable way: begin with a fresh beat, then honor every earlier beat with a pair of echoes. The result is always a single integer because the ritual never produces fractional sounds.

Think carefully about what happens when the pattern deepens. The power of the performance comes from stacking the earlier experience inside every new layer. Even a modest increase in levels can turn a quiet plaza into rolling sound, and festival planners rely on this rule to design each year's show.

Example 1:

Input: levels = 0
Output: 1
Explanation: Only the opening strike is heard, so the total is one beat.

Example 2:

Input: levels = 1
Output: 3
Explanation: The current level adds one beat, and the previous level echoes twice, resulting in three beats.

Example 3:

Input: levels = 4
Output: 31
Explanation: Four levels of echoes means a new beat plus twice the total experience of level three, producing thirty-one beats.

Related Problems

No related problems found

Comments (0)

Join the Discussion

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

BudiBadu Logo

Festival Drum Echoes

Recursion Easy 0 views

The Riverlight Drum Festival arrives with nightfall, when lanterns float above the river and the first drummer strikes a single resonant beat. The crowd falls silent as that note rolls across the water. Organizers describe each level of the celebration as a new circle of performers who wait for their cue, listening to how the earlier level responds, and then mirroring that momentum to keep the rhythm alive.

A whole number called levels controls how many layers follow the opening strike. Level zero represents only the first beat. For any higher level, the lead drummer introduces one new beat, and every beat from the previous level is answered twice to keep the echo alive beneath the cliffs. Listeners say the sound feels like thunder weaving through stone corridors, yet the pattern stays consistent no matter how many circles join in.

Your task is to report how many beats the audience hears by the end of the performance. The value of levels is never negative, and you do not skip levels. Each level expands the sound in the same dependable way: begin with a fresh beat, then honor every earlier beat with a pair of echoes. The result is always a single integer because the ritual never produces fractional sounds.

Think carefully about what happens when the pattern deepens. The power of the performance comes from stacking the earlier experience inside every new layer. Even a modest increase in levels can turn a quiet plaza into rolling sound, and festival planners rely on this rule to design each year's show.

Example 1:

Input: levels = 0
Output: 1
Explanation: Only the opening strike is heard, so the total is one beat.

Example 2:

Input: levels = 1
Output: 3
Explanation: The current level adds one beat, and the previous level echoes twice, resulting in three beats.

Example 3:

Input: levels = 4
Output: 31
Explanation: Four levels of echoes means a new beat plus twice the total experience of level three, producing thirty-one beats.

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.