HardPro challengePython

State

PythonDesign PatternsBehavioral

State lets an object change its behavior when its internal state
changes, by delegating to a state object instead of branching on a status
flag everywhere.

A Document moves draftreviewpublished each time
.publish() is called; calling it again once published is a no-op.
Implement DraftState, ReviewState and PublishedState, each
implementing .publish(doc) (transitions doc.state) and .name().

solve(actions_list) creates one fresh Document per entry and calls
.publish() that many times, returning the final .status() for each.

Sample tests

Test #1No publish calls stays draft
Input: [[0]]
Output: ["draft"]
Test #2One publish moves to review
Input: [[1]]
Output: ["review"]
Test #3Two publishes reaches published
Input: [[2]]
Output: ["published"]
Test #4Extra publish is a no-op once published
Input: [[3]]
Output: ["published"]