Given a list of movement commands (up, down, left, right, undo previous action), write a function that returns the final (x,y) coordinate. Followup: how would you handle other kinds of commands and undoing them? What kind of design pattern is this?
Sigiloso
Use a stack to store non-undo commands. For each command, use a dictionary to look up commands and perform their corresponding actions. Define several classes of commands (movement, attack, use item, etc) and if the action should be reversible, define an undo for them as well. Command design pattern