Cody

Problem 58. Tic Tac Toe FTW

Solution 2864339

Submitted on 21 Aug 2020 by Juan Berjón Díez
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(:)))

win_rows = 1 0 1 1 0 1 win_rows_idx = 7 8 9 1 4 7

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

win_rows = 0×3 empty double matrix win_rows_idx = 0×3 empty double matrix

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

win_rows = 1 0 1 1 1 0 win_rows_idx = 1 2 3 3 5 7

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

win_rows = 1 1 0 1 1 0 win_rows_idx = 1 5 9 3 5 7

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!