Cody

Problem 90. Connect Four Win Checker

Solution 452768

Submitted on 9 Jun 2014 by goc3
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
%% b = [0 1 1 0 2; 0 1 2 2 1; 1 0 2 2 2; 1 1 2 2 1; 1 1 2 1 0]; result_correct = 2; assert(isequal(c4winner(b),result_correct))

d = 00111 d = 11011 d = 12222 d = 02221 d = 21210 d_d1 = 001110000 d_d1 = 011011000 d_d1 = 001222200 d_d1 = 000022210 d_d1 = 000021210

2   Pass
%% b = [0 0 0 0; 1 0 2 0; 1 1 1 1; 0 0 2 2]; result_correct = 1; assert(isequal(c4winner(b),result_correct))

d = 0110 d = 0010 d = 0212 d = 0012 d_d1 = 0110000 d_d1 = 0001000 d_d1 = 0002120 d_d1 = 0000012

3   Pass
%% b = [0 0 0 0 0 1; 2 2 0 0 2 2; 0 0 0 0 0 1; 2 0 0 1 1 0; 0 0 0 1 0 0; 0 0 1 0 2 2]; result_correct = 1; assert(isequal(c4winner(b),result_correct))

d = 020200 d = 020000 d = 000001 d = 000110 d = 020102 d = 121002 d_d1 = 02020000000 d_d1 = 00200000000 d_d1 = 00000001000 d_d1 = 00000011000 d_d1 = 00000201020 d_d1 = 00000121002

4   Pass
%% b = [0 0 0 0; 1 0 0 0; 0 0 0 0; 0 0 0 2]; result_correct = 0; assert(isequal(c4winner(b),result_correct))

d = 0100 d = 0000 d = 0000 d = 0002 d_d1 = 0100000 d_d1 = 0000000 d_d1 = 0000000 d_d1 = 0000002

5   Pass
%% b = [0 0 0 0; 1 1 1 1; 0 0 0 0; 0 0 0 2]; result_correct = 1; assert(isequal(c4winner(b),result_correct))

d = 0100 d = 0100 d = 0100 d = 0102 d_d1 = 0100000 d_d1 = 0010000 d_d1 = 0001000 d_d1 = 0000102

6   Pass
%% b = [0 0 2 2; 1 0 2 0; 1 2 2 1; 2 0 1 2]; result_correct = 2; assert(isequal(c4winner(b),result_correct))

d = 0112 d = 0020 d = 2221 d = 2012 d_d1 = 0112000 d_d1 = 0002000 d_d1 = 0022210 d_d1 = 0002012

7   Pass
%% b = [0 0 0 0; 1 0 1 1; 0 0 2 0; 0 2 0 2]; result_correct = 0; assert(isequal(c4winner(b),result_correct))

d = 0100 d = 0002 d = 0120 d = 0102 d_d1 = 0100000 d_d1 = 0000200 d_d1 = 0001200 d_d1 = 0000102

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!