Sunday, 1 May 2011

X and O

Question:
 The game of Tic -Tac-Toe is played in a large square divided into nine small squares
1.Each of the two players in turn places his or her mark -usually X or O -in  a square.
2.The player who first gets three marks in a horizontal,vertical,or diagonal line wins.
3. A player will always place his or her marks in a line that already contains  (a)Two of his or her own marks
or (b) two of his or her opponent's marks- giving(a) priority  over (b)


X  1
O 2
3 
X 4
      5 
6 
O 7
O 8
X 9


=================================================================

Answer:
We have to find
 1.  Who will take the next move (either X or O)
 2. Where will the next move in the square takes place.
Here we will find  who had make the first move.
The cells are marked as 1,2,3,4,5,6,7,8,9

Here the next move will be in the cell 5 (either X or O)

The optimal solution is
*********************************************************
The first move is O at 2.
Next move will be X at  4.
Next move will be O at 7.
Next Move will be X at  1.
Next Move will be O at 8.
Next Move will be X at 9.
So next move will be O at 5 .and he will win
*********************************************************






No comments:

Post a Comment