Problem 44364. Is this a valid Tic Tac Toe State?
For the game of Tic Tac Toe we will be storing the state of the game in a matrix M.
For this game:
We would store the state as this:
-1 1 1 1 -1 -1 1 -1 -1
If there were any blanks squares, they would be 0;
For this challenge, X goes first. Neither side is compelled to take a win if possible. The game stops when either player wins.
For this challenge, is the the given board state 0: legal 1: this state can not occur in a game
The example in the image would return 0 because if X goes first there can never be more O than X. The state matrix will only hold [-1 0 1], so we are only checking for logic of the game.
Solution Stats
Problem Comments
-
6 Comments
It's difficult to say something about x=[1 -1 -1;0 1 -1;1 0 1].
Did X win after missing a win or did X continue to play after a win ?
Technically it's a legal state no ?
@Jean-Marie Sainthillier: If we'd number the nine cells of the grid as [1,4,7; 2,5,8; 3,6,9], then a series of moves that would lead to x = [1,-1,-1; 0,1,-1; 1,0,1] without "insensible" moves for X (the commencing party) would be: X:5, O:7, X:3, O:8, X:9, O:4, X:1 ; in that case, X did not miss a win nor continue to play after a win.
So it is controversial situation. I mean it is pretty legal situation
Solution Comments
Show commentsProblem Recent Solvers120
Suggested Problems
-
1436 Solvers
-
Number of 1s in the Binary Representation of a Number
456 Solvers
-
Duplicate each element of a vector.
616 Solvers
-
Get the elements of diagonal and antidiagonal for any m-by-n matrix
484 Solvers
-
Area of an equilateral triangle
6394 Solvers
More from this Author51
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!