Problem Statement

Let’s look at the game of Tic Tac Toe. Tic Tac Toe is a two-player strategy game played on a 3*3 grid. There are 9 empty cells and 9 pieces — 5 pieces of ‘X’ and 4 pieces of ‘O’

The game starts with an empty grid.

Rules of the game

  • The game is played between two players. One player owns the X pieces and can put it on any of the empty cells in the grid. The other player owns the O pieces and can in any of the empty cells.
  • The player with X makes the first turn. Each player plays alternately after that.
  • The first player to form a horizontal/vertical/diagonal sequence wins.