Aurora Diary Synthesis
The Archivists of Lumenfjord record each aurora using layered diary entries. Observers stationed at different cliff heights provide notes that wrap the previous observer’s perspective. The archivists insist that the final narration preserves every note and clearly states who is speaking, but the order is notoriously difficult to reconstruct once the aurora spans several hours. They ask for a program that will always reproduce the official narration exactly.
You are given two inputs. The first is root_line, a sentence written by the innermost observer (the person closest to the water). The second is observers, an array of records ordered from the closest observer outward. Each record contains two strings: name and insight. To produce the final narration, follow this recursive pattern:
- If there are no observers, the narration is simply
root_line. - Otherwise take the first observer, say
namewith insightinsight. Letinnerbe the narration produced by the remaining observers. The final narration becomes:{name} begins: {inner} {name} notes: {insight}
The archivists require the program to recurse until the outermost observer is processed. Line breaks must appear exactly as in the rule above. No extra whitespace is allowed. The result is a single string containing the entire narration.
Example 1:
Input: root_line = "Lights ripple over the tide.", observers = []
Output:
Lights ripple over the tide.
Example 2:
Input: root_line = "Lights ripple over the tide.", observers = [{"name": "Eira", "insight": "Green curtains meet the reef."}]
Output:
Eira begins:
Lights ripple over the tide.
Eira notes: Green curtains meet the reef.
Example 3:
Input: root_line = "A pale arc crowns the fjord.", observers = [{"name": "Kael", "insight": "Stars echo in the ice."}, {"name": "Lysa", "insight": "Upper bands split in two."}]
Output:
Kael begins:
Lysa begins:
A pale arc crowns the fjord.
Lysa notes: Upper bands split in two.
Kael notes: Stars echo in the ice.
Related Problems
No related problems found
Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this problem.
