Cody

# Problem 90. Connect Four Win Checker

Solution 2524257

Submitted on 11 Jun 2020 by Jerry Wright
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))

C = 5×5 logical array 0 1 1 0 0 0 1 0 0 1 1 0 0 0 0 1 1 0 0 1 1 1 0 1 0 win = logical 0 c = 1×5 logical array 0 1 1 0 0 win = logical 0 c = 1×5 logical array 0 1 0 0 1 win = logical 0 c = 1×5 logical array 1 0 0 0 0 win = logical 0 c = 1×5 logical array 1 1 0 0 1 win = logical 0 c = 1×5 logical array 1 1 0 1 0 win = logical 0 win = logical 0 c = 1×5 logical array 0 1 0 1 0 win = logical 0 c = 1×5 logical array 0 0 0 0 1 win = logical 0 c = 1×5 logical array 1 0 0 0 0 win = logical 0 c = 1×5 logical array 1 1 0 1 1 d = 1×6 logical array 1 0 1 1 0 1 n = 2 1 2 win = logical 0 win = logical 0 c = 1×5 logical array 0 0 1 1 1 win = logical 0 win = logical 0 nr = 5 c = 1×4 logical array 0 0 0 1 c = 1×4 logical array 0 0 0 1 win = logical 0 c = 1×5 logical array 0 1 0 0 0 c = 1×5 logical array 0 1 0 0 0 win = logical 0 c = 1×4 logical array 1 0 0 1 c = 1×4 logical array 1 0 0 1 win = logical 0 win = logical 0 nr = 5 c = 1×4 logical array 1 0 0 1 c = 1×4 logical array 1 0 0 1 win = logical 0 c = 1×5 logical array 1 1 0 0 0 c = 1×5 logical array 1 1 0 0 0 win = logical 0 c = 1×4 logical array 1 0 0 0 c = 1×4 logical array 1 0 0 0 win = logical 0 win = logical 0 C = 5×5 logical array 0 0 0 0 1 0 0 1 1 0 0 0 1 1 1 0 0 1 1 0 0 0 1 0 0 win = logical 0 c = 1×5 logical array 0 0 0 0 1 win = logical 0 c = 1×5 logical array 0 0 1 1 0 win = logical 0 c = 1×5 logical array 0 0 1 1 1 win = logical 0 c = 1×5 logical array 0 0 1 1 0 win = logical 0 c = 1×5 logical array 0 0 1 0 0 win = logical 0 win = logical 0 c = 1×5 logical array 1 0 1 0 0 win = logical 0 c = 1×5 logical array 0 1 1 1 0 win = logical 0 c = 1×5 logical array 0 1 1 1 1 d = 1×6 logical array 1 1 0 0 0 1 n = 1 4 win = logical 1 win = logical 1 win = logical 1 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))

C = 4×4 logical array 0 0 0 0 1 0 0 0 1 1 1 1 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 1 0 0 0 win = logical 0 c = 1×4 logical array 1 1 1 1 d = 1×5 logical array 1 0 0 0 1 n = 4 win = logical 1 win = logical 1 win = logical 1 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))

C = 6×6 logical array 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 win = logical 0 c = 1×6 logical array 0 0 0 0 0 1 win = logical 0 c = 1×6 logical array 0 0 0 0 0 0 win = logical 0 c = 1×6 logical array 0 0 0 0 0 1 win = logical 0 c = 1×6 logical array 0 0 0 1 1 0 win = logical 0 c = 1×6 logical array 0 0 0 1 0 0 win = logical 0 c = 1×6 logical array 0 0 1 0 0 0 win = logical 0 win = logical 0 c = 1×6 logical array 1 0 1 0 0 0 win = logical 0 c = 1×6 logical array 0 0 0 1 0 0 win = logical 0 c = 1×6 logical array 0 0 0 1 1 0 win = logical 0 c = 1×6 logical array 0 0 0 0 0 1 win = logical 0 c = 1×6 logical array 0 0 0 0 0 0 win = logical 0 c = 1×6 logical array 0 0 0 0 0 0 win = logical 0 win = logical 0 nr = 6 c = 1×4 logical array 0 0 0 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×5 logical array 0 0 0 1 0 c = 1×5 logical array 0 0 0 1 0 win = logical 0 c = 1×6 logical array 0 0 0 1 0 0 c = 1×6 logical array 0 0 0 1 0 0 win = logical 0 c = 1×5 logical array 0 0 0 1 0 c = 1×5 logical array 0 0 0 1 0 win = logical 0 c = 1×4 logical array 0 0 0 0 c = 1×4 logical array 0 0 0 0 win = logical 0 win = logical 0 nr = 6 c = 1×4 logical array 1 1 1 1 c = 1×4 logical array 1 1 1 1 d = 1×5 logical array 1 0 0 0 1 n = 4 win = logical 1 win = logical 1 win = logical 1 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))

C = 4×4 logical array 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 1 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 0 1 0 0 win = logical 0 win = logical 0 nr = 4 c = 1×4 logical array 0 0 0 0 c = 1×4 logical array 0 0 0 0 win = logical 0 win = logical 0 nr = 4 c = 1×4 logical array 0 0 0 0 c = 1×4 logical array 0 0 0 0 win = logical 0 win = logical 0 C = 4×4 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 1 win = logical 0 win = logical 0 c = 1×4 logical array 0 0 0 1 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 win = logical 0 nr = 4 c = 1×4 logical array 0 0 0 1 c = 1×4 logical array 0 0 0 1 win = logical 0 win = logical 0 nr = 4 c = 1×4 logical array 0 0 0 0 c = 1×4 logical array 0 0 0 0 win = logical 0 win = logical 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))

C = 4×4 logical array 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 1 1 1 1 d = 1×5 logical array 1 0 0 0 1 n = 4 win = logical 1 win = logical 1 win = logical 1 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))

C = 4×4 logical array 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 1 0 0 0 win = logical 0 c = 1×4 logical array 1 0 0 1 win = logical 0 c = 1×4 logical array 0 0 1 0 win = logical 0 win = logical 0 c = 1×4 logical array 0 0 1 0 win = logical 0 c = 1×4 logical array 0 0 0 1 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 0 1 1 0 win = logical 0 win = logical 0 nr = 4 c = 1×4 logical array 0 0 0 0 c = 1×4 logical array 0 0 0 0 win = logical 0 win = logical 0 nr = 4 c = 1×4 logical array 0 0 0 0 c = 1×4 logical array 0 0 0 0 win = logical 0 win = logical 0 C = 4×4 logical array 0 0 1 1 0 0 1 0 0 1 1 0 1 0 0 1 win = logical 0 c = 1×4 logical array 0 0 1 1 win = logical 0 c = 1×4 logical array 0 0 1 0 win = logical 0 c = 1×4 logical array 0 1 1 0 win = logical 0 c = 1×4 logical array 1 0 0 1 win = logical 0 win = logical 0 c = 1×4 logical array 1 0 0 1 win = logical 0 c = 1×4 logical array 1 1 1 0 win = logical 0 c = 1×4 logical array 0 0 1 0 win = logical 0 c = 1×4 logical array 0 0 0 1 win = logical 0 win = logical 0 nr = 4 c = 1×4 logical array 0 0 1 1 c = 1×4 logical array 0 0 1 1 win = logical 0 win = logical 0 nr = 4 c = 1×4 logical array 1 1 1 1 c = 1×4 logical array 1 1 1 1 d = 1×5 logical array 1 0 0 0 1 n = 4 win = logical 1 win = logical 1 win = logical 1 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))

C = 4×4 logical array 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 1 0 1 1 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 win = logical 0 c = 1×4 logical array 0 1 0 0 win = logical 0 c = 1×4 logical array 0 1 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 0 1 0 0 win = logical 0 win = logical 0 nr = 4 c = 1×4 logical array 0 0 0 0 c = 1×4 logical array 0 0 0 0 win = logical 0 win = logical 0 nr = 4 c = 1×4 logical array 0 0 1 0 c = 1×4 logical array 0 0 1 0 win = logical 0 win = logical 0 C = 4×4 logical array 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 c = 1×4 logical array 0 0 1 0 win = logical 0 c = 1×4 logical array 0 1 0 1 win = logical 0 win = logical 0 c = 1×4 logical array 0 0 0 1 win = logical 0 c = 1×4 logical array 0 0 1 0 win = logical 0 c = 1×4 logical array 0 0 0 1 win = logical 0 c = 1×4 logical array 0 0 0 0 win = logical 0 win = logical 0 nr = 4 c = 1×4 logical array 0 0 1 1 c = 1×4 logical array 0 0 1 1 win = logical 0 win = logical 0 nr = 4 c = 1×4 logical array 0 0 0 0 c = 1×4 logical array 0 0 0 0 win = logical 0 win = logical 0