BudiBadu Logo
00:00

Mirage Oasis Rings

Recursion Easy 0 views

Caravans crossing the Ardent Sands pause at Mirage Oasis to renew their bearings. The ritual begins by pouring a single ring of water into the basin, forming a gleaming mirror that reflects the stars. A steward then declares how many mirage rings will follow. Each new ring receives a fresh pour to mark the boundary, and the prior ring sprints outward in three shimmering copies, layering reflections that guide caravans back to their route.

Nomads revere the ceremony as a cosmic compass. Once the boundary water settles, the basin echoes the earlier ring on three sides, creating mirages that ripple across the dunes. The sequence never shifts: a new guiding pour, then triple the reflections of the earlier pattern. Even under erratic winds, the rule keeps the oasis maps reliable.

Your goal is to determine how many reflective rings travelers see when the final mirage settles. The input, rings, is a non-negative integer. When rings equals zero, only the initial pour mirrors the stars. For each additional ring, add one guiding pour and triple the entire display from the prior ring. Return the total ring count as an integer.

Example 1:

Input: rings = 0
Output: 1
Explanation: Only the first water mirror is visible.

Example 2:

Input: rings = 3
Output: 40
Explanation: Three rings repeat the pattern, generating forty mirrored arcs.

Example 3:

Input: rings = 5
Output: 364
Explanation: Five rings follow the ritual, producing three hundred sixty-four shimmering reflections.

Related Problems

No related problems found

Comments (0)

Join the Discussion

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

BudiBadu Logo

Mirage Oasis Rings

Recursion Easy 0 views

Caravans crossing the Ardent Sands pause at Mirage Oasis to renew their bearings. The ritual begins by pouring a single ring of water into the basin, forming a gleaming mirror that reflects the stars. A steward then declares how many mirage rings will follow. Each new ring receives a fresh pour to mark the boundary, and the prior ring sprints outward in three shimmering copies, layering reflections that guide caravans back to their route.

Nomads revere the ceremony as a cosmic compass. Once the boundary water settles, the basin echoes the earlier ring on three sides, creating mirages that ripple across the dunes. The sequence never shifts: a new guiding pour, then triple the reflections of the earlier pattern. Even under erratic winds, the rule keeps the oasis maps reliable.

Your goal is to determine how many reflective rings travelers see when the final mirage settles. The input, rings, is a non-negative integer. When rings equals zero, only the initial pour mirrors the stars. For each additional ring, add one guiding pour and triple the entire display from the prior ring. Return the total ring count as an integer.

Example 1:

Input: rings = 0
Output: 1
Explanation: Only the first water mirror is visible.

Example 2:

Input: rings = 3
Output: 40
Explanation: Three rings repeat the pattern, generating forty mirrored arcs.

Example 3:

Input: rings = 5
Output: 364
Explanation: Five rings follow the ritual, producing three hundred sixty-four shimmering reflections.

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.