Cody

# Problem 3690. OXO counting

Solution 2177138

Submitted on 26 Mar 2020
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
board = 'OXO'; y_correct = 1; assert(isequal(count_OXO(board),y_correct))

board = 'OXO' y = 1

2   Pass
board = ''; y_correct = 0; assert(isequal(count_OXO(board),y_correct))

board = 0×0 empty char array y = 0

3   Pass
board = ' '; y_correct = 0; assert(isequal(count_OXO(board),y_correct))

board = ' ' y = 0

4   Pass
board = ' X '; y_correct = 0; assert(isequal(count_OXO(board),y_correct))

board = ' X ' y = 0

5   Pass
board = 'O O'; y_correct = 0; assert(isequal(count_OXO(board),y_correct))

board = 'O O' y = 0

6   Pass
board = 'O O OXO X'; y_correct = 1; assert(isequal(count_OXO(board),y_correct))

board = 'O O OXO X' y = 1

7   Pass
board = 'OOX'; y_correct = 0; assert(isequal(count_OXO(board),y_correct))

board = 'OOX' y = 0

8   Pass
board = 'OOXOX'; y_correct = 1; assert(isequal(count_OXO(board),y_correct))

board = 'OOXOX' y = 1

9   Pass
board = 'OOX OX'; y_correct = 0; assert(isequal(count_OXO(board),y_correct))

board = 'OOX OX' y = 0

10   Pass
board = 'OOXXO'; y_correct = 0; assert(isequal(count_OXO(board),y_correct))

board = 'OOXXO' y = 0

11   Pass
board = 'OOXOOOOXXOXOX'; y_correct = 2; assert(isequal(count_OXO(board),y_correct))

board = 'OOXOOOOXXOXOX' y = 2

12   Fail
board = ['OOO';'OXO';'OXO']; y_correct = 4; assert(isequal(count_OXO(board),y_correct))

board = 3×3 char array 'OOO' 'OXO' 'OXO' y = 2

Assertion failed.

13   Fail
board = ['OOO';'OXO';'OOO']; y_correct = 4; assert(isequal(count_OXO(board),y_correct))

board = 3×3 char array 'OOO' 'OXO' 'OOO' y = 2

Assertion failed.

14   Fail
board = ['OXX';'XXX';'XOO']; y_correct = 1; assert(isequal(count_OXO(board),y_correct))

board = 3×3 char array 'OXX' 'XXX' 'XOO' y = 0

Assertion failed.

15   Pass
board = ['OOO';'X O';'OXO']; y_correct = 2; assert(isequal(count_OXO(board),y_correct))

board = 3×3 char array 'OOO' 'X O' 'OXO' y = 2

16   Pass
board = [' ';' ';' ';' ']; y_correct = 0; assert(isequal(count_OXO(board),y_correct))

board = 4×5 char array ' ' ' ' ' ' ' ' y = 0

17   Fail
board = ['O OO';'O XO';'OOX ']; y_correct = 1; assert(isequal(count_OXO(board),y_correct))

board = 3×4 char array 'O OO' 'O XO' 'OOX ' y = 0

Assertion failed.

18   Fail
board = ['OXXOXO';' OXO X';'XOXOXO']; y_correct = 6; assert(isequal(count_OXO(board),y_correct))

board = 3×6 char array 'OXXOXO' ' OXO X' 'XOXOXO' y = 3

Assertion failed.

19   Fail
board = ['OXOXOXO';'OXOXO X';'XOOOXOX']; y_correct = 8; assert(isequal(count_OXO(board),y_correct))

board = 3×7 char array 'OXOXOXO' 'OXOXO X' 'XOOOXOX' y = 4

Assertion failed.

20   Fail
board = 'OXO'.'; y_correct = 1; assert(isequal(count_OXO(board),y_correct))

board = 3×1 char array 'O' 'X' 'O'

Index in position 2 exceeds array bounds (must not exceed 1). Error in count_OXO (line 6) y=[y numel(regexp(board(i,:),'OXO')) numel(regexp(board(:,i)','OXO'))]; Error in Test20 (line 3) assert(isequal(count_OXO(board),y_correct))

21   Pass
% Keep in mind that Test Suite may be extended, so try to write general solution. % If you find any bugs, please report it to me. Thanks! % Have fun.