Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
n=32;
[vr]=solve_PerfectSqr_Seq(n);
% Verification of solutions for 32 thru 51
Tests=[1 1 1]; % start in Pass : Looks for fails
if n<33
sqrs=[4 9 16 25 36 49];
elseif n<41
sqrs=[4 9 16 25 36 49 64];
elseif n<51
sqrs=[4 9 16 25 36 49 64 81];
else % valid up thru n=61
sqrs=[4 9 16 25 36 49 64 81 100];
end
if isempty(vr)
Tests=[0 0 0];
else
% Check use all 1 thru 32
if length(unique(vr))~=n || max(vr)>n || min(vr)<1, Tests(1)=0;end
% Check Squareness
for i=1:length(vr)-1
if isempty(intersect(vr(i)+vr(i+1),sqrs))
Tests(2)=0;
end
end
% Check Ends Squareness
if isempty(intersect(vr(1)+vr(length(vr)),sqrs)),Tests(3)=0;end
end
assert(isequal(Tests,[1 1 1]));
You just got a free pass. Congrats!
|
2 | Pass |
%%
n=33;
[vr]=solve_PerfectSqr_Seq(n);
% Verification of solutions for 32 thru 51
Tests=[1 1 1]; % start in Pass : Looks for fails
if n<33
sqrs=[4 9 16 25 36 49];
elseif n<41
sqrs=[4 9 16 25 36 49 64];
elseif n<51
sqrs=[4 9 16 25 36 49 64 81];
else % valid up thru n=61
sqrs=[4 9 16 25 36 49 64 81 100];
end
if isempty(vr)
Tests=[0 0 0];
else
% Check use all 1 thru 32
if length(unique(vr))~=n || max(vr)>n || min(vr)<1, Tests(1)=0;end
% Check Squareness
for i=1:length(vr)-1
if isempty(intersect(vr(i)+vr(i+1),sqrs))
Tests(2)=0;
end
end
% Check Ends Squareness
if isempty(intersect(vr(1)+vr(length(vr)),sqrs)),Tests(3)=0;end
end
assert(isequal(Tests,[1 1 1]));
You just got a free pass. Congrats!
|
3 | Pass |
%%
n=41;
[vr]=solve_PerfectSqr_Seq(n);
% Verification of solutions for 32 thru 51
Tests=[1 1 1]; % start in Pass : Looks for fails
if n<33
sqrs=[4 9 16 25 36 49];
elseif n<41
sqrs=[4 9 16 25 36 49 64];
elseif n<51
sqrs=[4 9 16 25 36 49 64 81];
else % valid up thru n=61
sqrs=[4 9 16 25 36 49 64 81 100];
end
if isempty(vr)
Tests=[0 0 0];
else
% Check use all 1 thru 32
if length(unique(vr))~=n || max(vr)>n || min(vr)<1, Tests(1)=0;end
% Check Squareness
for i=1:length(vr)-1
if isempty(intersect(vr(i)+vr(i+1),sqrs))
Tests(2)=0;
end
end
% Check Ends Squareness
if isempty(intersect(vr(1)+vr(length(vr)),sqrs)),Tests(3)=0;end
end
assert(isequal(Tests,[1 1 1]));
You just got a free pass. Congrats!
|
1092 Solvers
Determine if a Given Number is a Triangle Number
322 Solvers
Back to basics 17 - white space
245 Solvers
We love vectorized solutions. Problem 1 : remove the row average.
546 Solvers
07 - Common functions and indexing 5
314 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!