Cody

Problem 58. Tic Tac Toe FTW

Solution 771190

Submitted on 4 Nov 2015 by Gareth Lee
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(:)))

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 y = Empty matrix: 0-by-1

2   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 y = 2 7

3   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 y = 7 9

Community Treasure Hunt

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

Start Hunting!