Cody

# Problem 90. Connect Four Win Checker

Solution 241991

Submitted on 9 May 2013 by Abhijit Badve
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))

ans = 0 c = 3 4 1 1 2 0 0 4 3 2 d = 2 1 2 2 1 3 3 2 3 1 ans = 2 c = 1 2 2 1 1 2 1 1 0 0 0 1 1 2 2 2 0 1 d = 3 0 4 0 1 4 1 3 2 2 ans = 2 c = 1 3 1 2 2 0 2 0 0 1 3 2 3 0 d = 2 1 2 2 1 3 3 2 3 1

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))

ans = 0 c = 2 1 1 1 0 0 2 1 d = 0 0 1 1 4 0 0 2 ans = 1 c = 1 2 1 1 0 1 1 1 d = 2 0 1 0 1 2 1 1 c = 1 1 1 1 1 0 0 0 1 0 1 1 d = 0 0 1 1 4 0 0 2 ans = 1

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))

ans = 0 c = 0 0 1 2 1 2 2 1 0 0 2 2 d = 1 0 0 4 1 0 2 1 1 0 1 2 c = 1 1 1 1 1 0 1 1 2 2 0 1 1 0 d = 0 2 0 1 1 0 2 0 1 2 2 2 c = 0 0 0 1 1 4 0 0 1 1 1 1 1 0 1 1 d = 1 0 0 4 1 0 2 1 1 0 1 2 ans = 1

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))

ans = 0 c = 1 0 0 0 0 0 0 1 d = 0 0 1 0 0 0 0 1 c = 1 0 0 1 d = 1 0 0 0 0 0 0 1 c = 1 0 0 1 d = 0 0 1 0 0 0 0 1

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))

ans = 0 c = 1 1 1 1 0 0 0 1 d = 0 0 4 0 0 0 0 1 ans = 1 c = 1 1 1 1 0 1 0 0 d = 1 0 1 0 1 0 1 1 c = 1 1 1 1 0 0 0 0 0 1 d = 0 0 4 0 0 0 0 1 ans = 1

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))

ans = 0 c = 2 0 1 1 1 1 3 2 d = 0 2 1 1 2 2 1 2 c = 0 1 2 0 1 0 0 1 0 1 2 1 1 1 d = 2 1 0 1 1 3 1 2 c = 1 1 0 0 2 0 0 1 4 1 0 1 d = 0 2 1 1 2 2 1 2 ans = 2

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))

ans = 0 c = 1 0 1 1 0 1 1 1 d = 0 0 3 0 0 1 0 2 c = 0 1 0 1 1 1 0 2 0 0 d = 1 0 0 1 1 1 1 1 c = 1 1 1 0 0 0 2 1 d = 0 0 3 0 0 1 0 2

### Community Treasure Hunt

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

Start Hunting!