Log inBook a Demo
BuildMidFrontendAuto-graded

Fix an undo history that replays stale commands

Catches whether someone realizes a fresh action after an undo must permanently discard the steps redo would replay.UndoRedo is the engine behind an editor's undo and redo. You drive it with commands and it maintains a state plus two stacks. The shipped version looks plausible and survives a happy-path click-through, but it is quietly broken in ways that corrupt user data — most notably replaying stale commands from a redo stack that should have been discarded. Make it honour the real contract, edges included.
35 min
python

You're done when

  • Performing a new command after an undo clears the redo stack, so stale commands can never be replayed.
  • Undo at the beginning of history does nothing rather than corrupting state.
  • Redo at the end of history does nothing.
  • Redo without a preceding undo does nothing.
  • When history exceeds its maximum length, the oldest entries are evicted correctly.

What it measures

Data structures and algorithmsKeeping two stacks and a state consistent across every operation, including at the boundaries.
Object-oriented programmingEnforcing an invariant inside a class so no sequence of public calls can break it.
Boundary thinkingHandling the empty-history and past-the-end cases, which is where undo implementations corrupt data.

Your environment

Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards

Start this lab

35 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.
AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo