Several implementations (C#, C++, JavaScript and TypeScript) of a finite state machine.