rows. Each character is 'X', 'O' or a space ' ' for an empty cell.
The rules:
- players take turns placing their own mark in an empty cell;
- the 'X' player always moves first, the 'O' player second;
- the game ends as soon as three identical marks fill a row, a column or a diagonal, or when no empty cells remain. No moves are made after that.
Return True if this position can come up in a fair game played by these rules, and False otherwise.rows=['XX ', 'OO ', ' '] → True
X has made two moves and O has made two, so it is X's turn. This position can happen.
rows=['OOO', 'XX ', 'XX '] → False
O completed a row, yet X has more marks: once O won, X could not have moved again.
rows=[' X', ' ', ' X'] → False
Two X marks and no O marks: players alternate, so this cannot happen.
rows=['XX ', 'OO ', ' ']
True
Run checks the first 3 tests in your browser. Submit checks all 93 tests on the server, hidden ones included.