β back to unit
Challenge
# stacks advanced
The Careful Librarian
The needed book is buried in the pile. The librarian narrates every single move while digging it out and restoring the rest. π€
You get the pile bottom to top and the book (exactly one copy). Print one line per move: off:<item> for each item moved to the side pile, take:<book> when the book comes off, then back:<item> for each item restored (in correct restore order).
Example:
Input: pile = ["atlas", "poems", "maps", "comics"], book = "poems"
Output:
off:comics
off:maps
take:poems
back:maps
back:comics
comics and maps get lifted off (top-down) to reach poems, then they're placed back in reverse β maps first, then comics.
π‘ need a hint?
stk-careful-librarian.pyπ given lines are locked β write your code in between
loading...