Harbor Tide Chants
Think of a small harbor challenge where order and timing really matter. In Harbor Tide Chants, you are trying to work toward the right number by following one clear idea.
Generate harbor tide chant recursively A good way to think about it is to first understand what goes in, then what rule you must follow, and finally what shape the answer should have.
For example, if the input is rolls = 2, the answer is 13. The second roll adds a verse and repeats the earlier chorus three times. Another example is rolls = 0, which gives 1. Only the caller sings, so one verse is heard.
This is a friendly practice problem, but it still rewards careful reading. The key is understanding the rule clearly and then applying it carefully.
One helpful habit is to say the rule out loud in your own words before you start solving. If you can explain what counts, what changes, and what the final answer should look like, you are already much closer to the right solution.
Example Input & Output
The second roll adds a verse and repeats the earlier chorus three times.
Only the caller sings, so one verse is heard.
Four rolls follow the rule, ending with one guiding verse plus triple the sound of roll three.
Algorithm Flow

Best Answers
class Solution {
public int harbor_tide_chants(int rolls) {
int result = 1;
for (int i = 0; i < rolls; i++) {
result = 1 + 3 * result;
}
return result;
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
