Cody

# Problem 58. Tic Tac Toe FTW

Solution 719358

Submitted on 21 Aug 2015 by Ian Riley
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(:)))

check = 1 2 3 4 5 6 7 8 9 1 4 7 2 5 8 3 6 9 1 5 9 3 5 7 wins = [] wincheck = 0 -2 2 2 -1 -1 1 -1 atemp = 1 0 1 1 -1 0 -1 -1 1 wincheck = 1 -2 2 2 0 -1 1 -1 wincheck = 0 -2 2 2 -1 -1 1 -1 atemp = 1 1 1 0 -1 0 -1 -1 1 wincheck = 0 -1 2 3 -1 -1 1 -1 wins = 4 wincheck = 0 -2 2 2 -1 -1 1 -1 wincheck = 0 -2 2 2 -1 -1 1 -1 wincheck = 0 -2 2 2 -1 -1 1 -1 atemp = 1 0 1 0 -1 1 -1 -1 1 wincheck = 0 -2 3 2 0 -1 1 -1 wins = 4 8 wincheck = 0 -2 2 2 -1 -1 1 -1 check = 1 2 3 4 5 6 7 8 9 1 4 7 2 5 8 3 6 9 1 5 9 3 5 7 wins = [] wincheck = 0 -1 1 1 -1 0 1 -2 atemp = 1 0 0 1 -1 0 -1 0 1 wincheck = 1 -1 1 1 0 0 1 -2 wincheck = 0 -1 1 1 -1 0 1 -2 atemp = 1 1 0 0 -1 0 -1 0 1 wincheck = 0 0 1 2 -1 0 1 -2 wincheck = 0 -1 1 1 -1 0 1 -2 atemp = 1 0 0 0 -1 0 -1 1 1 wincheck = 0 0 1 1 -1 1 1 -2 atemp = 1 0 1 0 -1 0 -1 0 1 wincheck = 0 -1 2 2 -1 0 1 -1 atemp = 1 0 0 0 -1 1 -1 0 1 wincheck = 0 -1 2 1 0 0 1 -2 wincheck = 0 -1 1 1 -1 0 1 -2 wins = 0

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

check = 1 2 3 4 5 6 7 8 9 1 4 7 2 5 8 3 6 9 1 5 9 3 5 7 wins = [] wincheck = 2 0 -2 1 0 -1 1 2 atemp = 1 0 0 1 1 -1 1 -1 -1 wincheck = 3 0 -2 1 1 -1 1 2 wins = 2 wincheck = 2 0 -2 1 0 -1 1 2 atemp = 1 1 0 0 1 -1 1 -1 -1 wincheck = 2 1 -2 2 0 -1 1 2 wincheck = 2 0 -2 1 0 -1 1 2 wincheck = 2 0 -2 1 0 -1 1 2 atemp = 1 0 1 0 1 -1 1 -1 -1 wincheck = 2 0 -1 2 0 -1 1 3 wins = 2 7 wincheck = 2 0 -2 1 0 -1 1 2 wincheck = 2 0 -2 1 0 -1 1 2

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

check = 1 2 3 4 5 6 7 8 9 1 4 7 2 5 8 3 6 9 1 5 9 3 5 7 wins = [] wincheck = 1 0 -1 1 -1 0 2 2 wincheck = 1 0 -1 1 -1 0 2 2 wincheck = 1 0 -1 1 -1 0 2 2 atemp = 1 1 0 -1 1 -1 1 -1 0 wincheck = 1 1 -1 2 -1 0 2 2 wincheck = 1 0 -1 1 -1 0 2 2 wincheck = 1 0 -1 1 -1 0 2 2 atemp = 1 0 1 -1 1 -1 1 -1 0 wincheck = 1 0 0 2 -1 0 2 3 wins = 7 wincheck = 1 0 -1 1 -1 0 2 2 atemp = 1 0 0 -1 1 -1 1 -1 1 wincheck = 1 0 0 1 -1 1 3 2 wins = 7 9

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!