Cody

# Problem 633. Create Circular Perfect Square Sequence

Solution 316209

Submitted on 6 Sep 2013 by James
• Size: 100
• This is the leading solution.
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
%% 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!