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, given a game state, does X (1) have a three in a row on any row, column or major diagonal?
Solution 7 should be correct. The diagonal of -1s is a valid win.
Hope all is well with you, Doug!
@Sean, I think Doug's got it right. He's asking only if the X side (that is +1) is in a winning position. In test 7, the O side (-1) is in a winning position. So the answer given is correct.
Shouldn't Test 7 be y_correct = 1?
To be fair, you didn't mention anything about anti-diagonal in your problem description (test no. 4). Or am I missing something?
Convert a vector into a number
442 Solvers
Is this triangle right-angled?
1370 Solvers
179 Solvers
Digit concentration in Champernowne's constant
102 Solvers
A Simple Tide Gauge with MATLAB
300 Solvers