Sorry for my english... but i can not understand why the test 6 has y_correct=0. I think that my problem is in understanding the problem description.
In test 6, player 2 (-1) wins but player 1 (1) continues to play.
I would miss illegal x=[1 -1 -1;0 1 -1;0 0 1].
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
Now this is elegant!
It is not a general solution. It would fail on:
x = [ 1 1 -1; -1 1 -1; -1 1 0];
y_correct = 0;
PS: The game ended but O kept on playing.
It seems to me that this solution unintentionally messed up its last code line and got lucky with the test suite, because this solution would not correctly identify x = [1,0,0; 0,0,0; 0,0,0] or x = [-1,-1,-1; 1,1,0; 1,0,0] as valid Tic-Tac-Toe states. Unless your very purpose was to actually expose/exploit this "shortcoming" in the test suite, of course! :-)
Thanks for your comment. I was confused by the original problem description such as "state 0: legal 1: this state", where the extra colons seem to be misleading. After some digging, I have figured out the rationale of Tic-Tac-Toe, and thus, updated my solutions.
Thanks for your reply, Peng Liu. I'll admit, I too was (and still am) confused by the "state 0: legal 1: this state" sentence in the problem description. Luckily I was already familiar with the Tic-Tac-Toe game.
Hi, yurenchu & Peng Liu. I agree the punctuation and syntax are very confusing, and indeed misleading. As written it seems to define 0 as representing legal states — which, besides being unusual (although possible), is contrary to the Test Suite and the example above. A clearer way to state the sentence may be: "For this challenge please categorise the given board state as either 1 = legal state, or 0 = illegal state (cannot occur in a game)."
Not a proper solution; it would incorrectly identify x = [1 1 1; -1 -1 -1; 1 0 0] as a valid state.
Ignore my previous comment; I was mistaken when I wrote that (and apparently I can't delete it).
The bug with deleting comments on problems or solutions appears to be longstanding. See https://au.mathworks.com/matlabcentral/cody/problems/43708
Thanks for the link, David Verrelli. I seem to remember that the "Delete" button did work in the not-too-distant-past (a few months ago), but maybe I'm misremembering things. However, to be honest, I don't mind this bug as much because I think it's a good thing that a comment can't be deleted when it has already received replies; otherwise a thread of comments would become unreadable. It's only when an erroneous comment of mine hasn't received any replies yet and the "Delete" button turns out to be non-functional that I experience a slight "Aaargghh!" moment, because the presence of the "Delete" button created different expectations. :-) But I don't really mind leaving my erroneous comment up and correcting myself in a new comment, as I did above.
Yurenchu, I agree that if a comment has received replies it's generally best not to delete it.
Make a checkerboard matrix
Find the peak 3n+1 sequence value
Project Euler: Problem 10, Sum of Primes
Back to basics 8 - Matrix Diagonals
Convert a vector into a number
Flag largest magnitude swings as they occur
Is this is a Tic Tac Toe X Win?
Project Euler: Problem 3, Largest prime factor
String substitution, sub problem to cryptoMath
Project Euler: Problem 7, Nth prime
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office