Match Referee
Mediumsimulationstate machine
A referee bot reads match events in order and keeps the score. A match is in one of four states: waiting, running, paused or over, and starts waiting.
- start moves waiting to running.
- pause moves running to paused; resume moves paused to running.
- goal A and goal B add a point for that team, but only while running.
- end moves running or paused to over.
- Any event that does not apply in the current state is ignored, and every event after over is ignored.
Return [scoreA, scoreB, state] after all events, where state is the final state's name.
Examples
Input: events = ["start","goal A","pause","goal B","resume","goal B","end","goal A"]
Output: [1,1,"over"]
Input: events = ["goal A","pause"]
Output: [0,0,"waiting"]