Cody

# Problem 58. Tic Tac Toe FTW

Solution 407991

Submitted on 22 Feb 2014 by Marco Castelli
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 1 0 -1 0 -1 -1 1]; b = [4 8]; out = ticTacToe(a); assert(isequal(out(:), b(:)))

ans = 1 2 3 1 4 7 1 5 9 2 3 1 2 5 8 3 1 2 3 5 7 3 6 9 4 5 6 4 7 1 5 6 4 5 7 3 5 8 2 5 9 1 6 9 3 6 4 5 7 8 9 7 1 4 7 3 5 8 9 7 8 2 5 9 1 5 9 3 6 9 7 8 ans = 4 8

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

ans = 1 2 3 1 4 7 1 5 9 2 3 1 2 5 8 3 1 2 3 5 7 3 6 9 4 5 6 4 7 1 5 6 4 5 7 3 5 8 2 5 9 1 6 9 3 6 4 5 7 8 9 7 1 4 7 3 5 8 9 7 8 2 5 9 1 5 9 3 6 9 7 8 ans = 0×1 empty double column vector

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

ans = 1 2 3 1 4 7 1 5 9 2 3 1 2 5 8 3 1 2 3 5 7 3 6 9 4 5 6 4 7 1 5 6 4 5 7 3 5 8 2 5 9 1 6 9 3 6 4 5 7 8 9 7 1 4 7 3 5 8 9 7 8 2 5 9 1 5 9 3 6 9 7 8 ans = 2 7

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

ans = 1 2 3 1 4 7 1 5 9 2 3 1 2 5 8 3 1 2 3 5 7 3 6 9 4 5 6 4 7 1 5 6 4 5 7 3 5 8 2 5 9 1 6 9 3 6 4 5 7 8 9 7 1 4 7 3 5 8 9 7 8 2 5 9 1 5 9 3 6 9 7 8 ans = 7 9

### Community Treasure Hunt

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

Start Hunting!