β back to unit
Medium
# stacks medium
Rooms Within Rooms
The castle has rooms inside rooms β your position is the whole chain of doors you walked through. π°
You start in castle. You get commands β enter:kitchen or exit (never exiting the castle itself). Print your final position as the chain joined by /, like castle/hall/library.
Example:
Input: commands = ["enter:hall", "enter:library", "exit", "enter:tower"]
Output: castle/hall/tower
Entering hall then library builds castle/hall/library. exit pops library off. Then entering tower builds castle/hall/tower.
π‘ need a hint?
stk-rooms-within-rooms.pyπ given lines are locked β write your code in between
loading...