Ember Nest Flames
In the Emberfold Valley, villagers close the dusk market by lighting a communal hearth carved into the mountainside. The firekeepers begin with one glowing coal set deep in a circular stone nest. A town crier then announces how many additional ember rings will surround the first coal. For each new ring, the firekeepers lay a fresh coal to mark the boundary, and then every spark from the previous ring is echoed fourfold by carefully angled mirrors, sending their glow back into the heart of the fire.
The ritual never changes. As soon as the boundary coal warms the next ring, the tenders encourage every ember from below to flare in four directions, reflecting from the polished stone to celebrate the changing winds. Travellers say the hillside looks like a layered sunrise climbing the rock, but underneath the beauty lies a predictable rhythm: place a new coal, then invite the earlier light to bloom exactly four times over. No shortcuts or improvisations are allowed; the elders believe that keeping the ratio constant wards off sudden storms.
Your goal is to determine the total number of glowing embers visible once the final ring settles. The input is a non-negative integer named rings, representing how many layers wrap the base coal. When rings equals zero, only the original coal shines. For higher values, repeat the precise pattern of one fresh coal plus four times the light from the prior ring. Return an integer describing the total embers glowing at the end of the ceremony.
Example 1:
Input: rings = 0
Output: 1
Explanation: Only the first coal remains.
Example 2:
Input: rings = 2
Output: 85
Explanation: The second ring adds a boundary coal and multiplies the previous glow fourfold, for a total of eighty-five embers.
Example 3:
Input: rings = 4
Output: 1365
Explanation: Four extra rings mean the latest coal plus four times the entire light from ring three.
Related Problems
No related problems found
Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this problem.
