Can someone please tell me whats going on?!
The reshape function creates a matrix with the vector [1 3 9 27] placed vertically, horizontally, and diagonally; the conv2 function does sort of a dot product of these with all sets of four elements in the test matrix; if [1 1 1 1] or [2 2 2 2] appears, the result will be 40 or 80, respectively.
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))
|
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))
|
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))
|
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))
|
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))
|
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))
|
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))
|
5703 Solvers
Find common elements in matrix rows
1231 Solvers
965 Solvers
07 - Common functions and indexing 6
348 Solvers
2770 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!