BudiBadu Logo
00:00

Harbor Tide Chants

Recursion Easy 0 views

Each new moon, the singers of Port Meridian greet incoming ships with the Harbor Tide Chant. The ritual begins with a lone caller standing on the docks, releasing a single verse that ripples over the water. Before the choir continues, the harbor master announces how many tide rolls will answer that night. Every tide roll begins with one guiding verse so the boats know when to echo, and the seawalls send the previous roll's melody back three times, weaving harmonies that bounce between lighthouse and jetty.

Locals say the pattern steadies the crews as they align their rigging. As soon as the guiding verse sounds, the harbor's stone arches reflect the earlier roll from three angles, producing bright chords that fold into the sea breeze. No one improvises; centuries of storms taught the community that consistency keeps the flotilla safe.

Your task is to calculate the total number of verses the sailors hear by the time the final tide roll finishes. The input is a non-negative integer rolls. When rolls equals zero, only the opening verse rings out. For each additional roll, add one guiding verse and triple the entire chorus from the previous roll. Return an integer representing how many verses echo across the harbor when the chant concludes.

Example 1:

Input: rolls = 0
Output: 1
Explanation: Only the caller sings, so one verse is heard.

Example 2:

Input: rolls = 2
Output: 13
Explanation: The second roll adds a verse and repeats the earlier chorus three times.

Example 3:

Input: rolls = 4
Output: 121
Explanation: Four rolls follow the rule, ending with one guiding verse plus triple the sound of roll 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

Harbor Tide Chants

Recursion Easy 0 views

Each new moon, the singers of Port Meridian greet incoming ships with the Harbor Tide Chant. The ritual begins with a lone caller standing on the docks, releasing a single verse that ripples over the water. Before the choir continues, the harbor master announces how many tide rolls will answer that night. Every tide roll begins with one guiding verse so the boats know when to echo, and the seawalls send the previous roll's melody back three times, weaving harmonies that bounce between lighthouse and jetty.

Locals say the pattern steadies the crews as they align their rigging. As soon as the guiding verse sounds, the harbor's stone arches reflect the earlier roll from three angles, producing bright chords that fold into the sea breeze. No one improvises; centuries of storms taught the community that consistency keeps the flotilla safe.

Your task is to calculate the total number of verses the sailors hear by the time the final tide roll finishes. The input is a non-negative integer rolls. When rolls equals zero, only the opening verse rings out. For each additional roll, add one guiding verse and triple the entire chorus from the previous roll. Return an integer representing how many verses echo across the harbor when the chant concludes.

Example 1:

Input: rolls = 0
Output: 1
Explanation: Only the caller sings, so one verse is heard.

Example 2:

Input: rolls = 2
Output: 13
Explanation: The second roll adds a verse and repeats the earlier chorus three times.

Example 3:

Input: rolls = 4
Output: 121
Explanation: Four rolls follow the rule, ending with one guiding verse plus triple the sound of roll 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.