# stacks advanced

The Grand Un-Stacker

Final boss of the stack unit: a machine with four buttons. πŸŽ›οΈ

You get commands β€” push:x, pop, swap (exchange the top TWO), dup (push a copy of the top). All commands arrive only when legal. Print the final stack bottom to top, comma-separated, or empty.

Example:

Input: commands = ["push:a", "push:b", "swap", "dup"] Output: b,a,a

Pushing a then b gives [a, b]. swap trades the top two to [b, a]. dup copies the top a, giving [b, a, a].

πŸ’‘ need a hint?

stk-grand-unstacker.pyπŸ”’ given lines are locked β€” write your code in between
loading...