All problems

Shared props appear more than once in a shadow theatre manifest

Level 2 · node · Data · Unique prop collection in an acyclic graph with shared descendants

Scenario

A fictional shadow theatre workshop organizes performances into scene groups and individual props. Multiple scenes may refer to the same physical prop, and a scene group may contain other scene groups. The preparation manifest used by the transport crew must list each prop identifier only once, but shared props appear on multiple lines. The structure is a directed acyclic graph, and every child reference points to a registered item.

Requirements

Return the identifiers of reachable individual props once each, in first-discovery order. Do not include scene groups themselves. Return an empty array for an unregistered starting item, and keep queries for different performances independent.

Acceptance criteria

  • For nested scenes without shared items, collect props depth-first from left to right.
  • When different scenes refer to the same physical prop, return it only once at its first-discovery position.
  • Return a single identifier for an individual prop as the starting item and an empty array for an unregistered item.
  • Repeated queries and queries for other performances must not be affected by previous queries.