Cody

# Problem 58. Tic Tac Toe FTW

Solution 1487916

Submitted on 11 Apr 2018 by Yanni Wang
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
a = [ 1 0 0 0 -1 0 -1 0 1]; b = [0]; out = ticTacToe(a); assert(isequal(out(:), b(:)))

next_position = 2 4 6 7 8 a = 1 0 0 1 -1 0 -1 0 1 s = 1 0 0 1 1 -1 1 -1 1 -1 0 0 -1 0 -1 -1 -1 0 1 0 0 1 1 0 wins = 0 a = 1 0 0 0 -1 0 -1 0 1 a = 1 1 0 0 -1 0 -1 0 1 s = 1 1 0 1 0 -1 1 -1 0 -1 0 1 -1 0 -1 -1 -1 0 1 0 0 1 1 0 wins = 0 0 a = 1 0 0 0 -1 0 -1 0 1 a = 1 0 0 0 -1 0 -1 1 1 s = 1 0 0 1 0 -1 1 -1 0 -1 0 0 -1 1 -1 -1 -1 1 1 0 0 1 1 0 wins = 0 0 0 a = 1 0 0 0 -1 0 -1 0 1 a = 1 0 1 0 -1 0 -1 0 1 s = 1 0 1 1 0 -1 1 -1 0 -1 0 0 -1 0 -1 -1 -1 0 1 1 0 1 1 1 wins = 0 0 0 0 a = 1 0 0 0 -1 0 -1 0 1 a = 1 0 0 0 -1 1 -1 0 1 s = 1 0 0 1 0 -1 1 -1 0 -1 1 0 -1 0 -1 -1 -1 0 1 0 1 1 1 0 wins = 0 0 0 0 0 a = 1 0 0 0 -1 0 -1 0 1 wins = 1×0 empty double row vector wins = 0

2   Pass
a = [ 1 0 0 0 1 -1 1 -1 -1]; b = [2 7]; out = ticTacToe(a); assert(isequal(out(:), b(:)))

next_position = 2 4 7 a = 1 0 0 1 1 -1 1 -1 -1 s = 1 0 0 1 1 1 1 1 1 1 -1 0 1 -1 1 1 1 -1 -1 0 -1 -1 -1 0 a = 1 0 0 0 1 -1 1 -1 -1 a = 1 1 0 0 1 -1 1 -1 -1 s = 1 1 0 1 0 1 1 1 0 1 -1 1 1 -1 1 1 1 -1 -1 0 -1 -1 -1 0 wins = 2 0 a = 1 0 0 0 1 -1 1 -1 -1 a = 1 0 1 0 1 -1 1 -1 -1 s = 1 0 1 1 0 1 1 1 0 1 -1 0 1 -1 1 1 1 -1 -1 1 -1 -1 -1 1 a = 1 0 0 0 1 -1 1 -1 -1 wins = 2 7

3   Pass
a = [ 1 0 0 -1 1 -1 1 -1 0]; b = [7 9]; out = ticTacToe(a); assert(isequal(out(:), b(:)))

next_position = 4 7 9 a = 1 1 0 -1 1 -1 1 -1 0 s = 1 1 0 1 -1 1 1 1 -1 1 -1 1 1 -1 1 1 1 -1 0 0 -1 0 0 0 wins = 0 a = 1 0 0 -1 1 -1 1 -1 0 a = 1 0 1 -1 1 -1 1 -1 0 s = 1 0 1 1 -1 1 1 1 -1 1 -1 0 1 -1 1 1 1 -1 0 1 -1 0 0 1 a = 1 0 0 -1 1 -1 1 -1 0 a = 1 0 0 -1 1 -1 1 -1 1 s = 1 0 0 1 -1 1 1 1 -1 1 -1 0 1 -1 1 1 1 -1 1 0 -1 1 1 0 a = 1 0 0 -1 1 -1 1 -1 0 wins = 7 9