Cody

Problem 90. Connect Four Win Checker

Solution 2268061

Submitted on 10 May 2020 by shaikh akbar shaikh rasul
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))

x1 = 3 4 5 1 2 4 5 1 5 2 4 y1 = 1 1 1 2 2 2 2 3 4 5 5 x2 = 2 3 4 5 2 3 4 1 3 y2 = 3 3 3 3 4 4 4 5 5 result = 2

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

x1 = 2 3 3 3 3 y1 = 1 1 2 3 4 x2 = 2 4 4 y2 = 3 3 4 result = 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))

x1 = 6 4 5 4 1 3 y1 = 3 4 4 5 6 6 x2 = 2 4 2 2 6 2 6 y2 = 1 1 2 5 5 6 6 result = 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))

x1 = 2 y1 = 1 x2 = 4 y2 = 4 result = 0

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

x1 = 2 2 2 2 y1 = 1 2 3 4 x2 = 4 y2 = 4 result = 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))

x1 = 2 3 4 3 y1 = 1 1 3 4 x2 = 4 3 1 2 3 1 4 y2 = 1 2 3 3 3 4 4 result = 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))

x1 = 2 2 2 y1 = 1 3 4 x2 = 4 3 4 y2 = 2 3 4 result = 0

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!