The following solution, which is correct, is marked wrong.
function a = checkerboard(n)
a = ones(n);
a(2:2:end) = 0;
end
lol
Maybe it is right for a determined "n", but for other values it's wrong, that is why it does several tests.
not valid for even value of n. plz recheck it
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
n = 5;
a = [1 0 1 0 1;
0 1 0 1 0;
1 0 1 0 1;
0 1 0 1 0;
1 0 1 0 1];
assert(isequal(a,checkerboard(n)))
|
2 | Fail |
n = 4;
a = [1 0 1 0;
0 1 0 1;
1 0 1 0;
0 1 0 1];
assert(isequal(a,checkerboard(n)))
|
3 | Pass |
n = 7;
a = [1 0 1 0 1 0 1
0 1 0 1 0 1 0
1 0 1 0 1 0 1
0 1 0 1 0 1 0
1 0 1 0 1 0 1
0 1 0 1 0 1 0
1 0 1 0 1 0 1];
assert(isequal(a,checkerboard(n)))
|
819 Solvers
Back to basics 3 - Temp Directory
328 Solvers
Back to basics 12 - Input Arguments
525 Solvers
579 Solvers
How many trades represent all the profit?
520 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!