Finite State Machines

Code

Image courtesy: AI - Copilot