See Note 2 in the problem description.
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
n = 5;
a = no_recs(n);
d = size(a);
assert(isequal(d,[n n]));
% Only the numbers 1:4
tf = isempty(setdiff(a,[1 2 3 4]));
assert(tf)
% No rectangles
tf = ~any(arrayfun(@(n)any(sum((a==n)'*double(a==n)>1)>1),1:4));
assert(tf)
|
2 | Pass |
%%
n = 8;
a = no_recs(n);
d = size(a);
assert(isequal(d,[n n]));
% Only the numbers 1:4
tf = isempty(setdiff(a,[1 2 3 4]));
assert(tf)
% No rectangles
tf = ~any(arrayfun(@(n)any(sum((a==n)'*double(a==n)>1)>1),1:4));
assert(tf)
|
3 | Pass |
%%
n = 12;
a = no_recs(n);
d = size(a);
assert(isequal(d,[n n]));
% Only the numbers 1:4
tf = isempty(setdiff(a,[1 2 3 4]));
assert(tf)
% No rectangles
tf = ~any(arrayfun(@(n)any(sum((a==n)'*double(a==n)>1)>1),1:4));
assert(tf)
|
Select every other element of a vector
20334 Solvers
88 Solvers
Back to basics 8 - Matrix Diagonals
781 Solvers
148 Solvers
Triangular matrices in 3D array
62 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!