I’ve coded the Tock game so many times :
Play a game now
The NodeJS version
The Haskell version Best