BudiBadu Logo
00:00

Lantern Pattern Paths

Recursion Medium 0 views

At the Festival of Threads, architects illuminate a riverside maze with lantern arcs that shimmer above the tide. The design always begins with a single walkway, described by a short phrase that tells visitors when to pause and look up. Curators then announce how many mirrored corridors will wrap around that walkway. Each corridor has a signature name—such as "Azure Bridge" or "Golden Spine"—and ushers recite a predictable rhythm when guiding guests through the added layer.

The rhythm never changes. To surround an inner layout with a corridor named marker, ushers first say "Enter {marker}" while stepping into the new lights. They let guests experience the inner layout completely, then whisper "Mirror {marker}" to signal the balanced return, replay the inner layout again, and finally announce "Exit {marker}" to close the loop. When no corridors remain, the only phrase spoken is the base walkway description. Each layer therefore wraps the inner list of phrases with three new lines and a second pass through the inner path, creating a woven experience that still respects the original center.

You must list every phrase in the order the ushers speak them. The input provides base, the innermost walkway phrase, and markers, an array of corridor names ordered from the closest layer outward. Return an array of strings describing the full script. If markers is empty, return an array containing only base. Otherwise process the markers recursively: the first element wraps the base, the second wraps that result, and so on.

Example 1:

Input: base = "Pause by the willow.", markers = []
Output: ["Pause by the willow."]

Example 2:

Input: base = "Pause by the willow.", markers = ["Azure Bridge"]
Output: ["Enter Azure Bridge", "Pause by the willow.", "Mirror Azure Bridge", "Pause by the willow.", "Exit Azure Bridge"]

Example 3:

Input: base = "Listen for distant bells.", markers = ["Golden Spine", "Silver Veil"]
Output: ["Enter Golden Spine", "Enter Silver Veil", "Listen for distant bells.", "Mirror Silver Veil", "Listen for distant bells.", "Exit Silver Veil", "Mirror Golden Spine", "Enter Silver Veil", "Listen for distant bells.", "Mirror Silver Veil", "Listen for distant bells.", "Exit Silver Veil", "Exit Golden Spine"]

Related Problems

No related problems found

Comments (0)

Join the Discussion

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

BudiBadu Logo

Lantern Pattern Paths

Recursion Medium 0 views

At the Festival of Threads, architects illuminate a riverside maze with lantern arcs that shimmer above the tide. The design always begins with a single walkway, described by a short phrase that tells visitors when to pause and look up. Curators then announce how many mirrored corridors will wrap around that walkway. Each corridor has a signature name—such as "Azure Bridge" or "Golden Spine"—and ushers recite a predictable rhythm when guiding guests through the added layer.

The rhythm never changes. To surround an inner layout with a corridor named marker, ushers first say "Enter {marker}" while stepping into the new lights. They let guests experience the inner layout completely, then whisper "Mirror {marker}" to signal the balanced return, replay the inner layout again, and finally announce "Exit {marker}" to close the loop. When no corridors remain, the only phrase spoken is the base walkway description. Each layer therefore wraps the inner list of phrases with three new lines and a second pass through the inner path, creating a woven experience that still respects the original center.

You must list every phrase in the order the ushers speak them. The input provides base, the innermost walkway phrase, and markers, an array of corridor names ordered from the closest layer outward. Return an array of strings describing the full script. If markers is empty, return an array containing only base. Otherwise process the markers recursively: the first element wraps the base, the second wraps that result, and so on.

Example 1:

Input: base = "Pause by the willow.", markers = []
Output: ["Pause by the willow."]

Example 2:

Input: base = "Pause by the willow.", markers = ["Azure Bridge"]
Output: ["Enter Azure Bridge", "Pause by the willow.", "Mirror Azure Bridge", "Pause by the willow.", "Exit Azure Bridge"]

Example 3:

Input: base = "Listen for distant bells.", markers = ["Golden Spine", "Silver Veil"]
Output: ["Enter Golden Spine", "Enter Silver Veil", "Listen for distant bells.", "Mirror Silver Veil", "Listen for distant bells.", "Exit Silver Veil", "Mirror Golden Spine", "Enter Silver Veil", "Listen for distant bells.", "Mirror Silver Veil", "Listen for distant bells.", "Exit Silver Veil", "Exit Golden Spine"]

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.