Tic Tac Toe!

This is a very common tech test as it demonstrates a candidate's knowledge of basic data structures.

The brief

The rules of tic-tac-toe are as follows:

  • There are two symbols in the game (default x and o)
  • Players take turns until the game is over
  • A player can claim a field if it is not already taken
  • A player wins if they claim all the fields in a row, column or diagonal
  • A game is over if a player wins or when all fields are taken

Build the business logic for a game of tic tac toe. It should be easy to implement a working game of tic tac toe by combining your code with any user interface, whether web or command line.