Cody

Solution 550736

Submitted on 30 Dec 2014 by rifat
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
%% format long format compact seed=clock; seed=1000*seed(6); rng(seed) n=4; % Create a Unique element square array M=randperm(n*n); M=reshape(M,n,n) vr=M(1:n,:); vr=sortrows(vr); vc=M(:,1:n); vc=sortrows(vc')'; tic M_out=Criss_Cross(vr,vc); toc M_out assert(isequal(M,M_out));

M = 1 16 9 6 2 4 11 10 3 12 15 5 13 14 7 8 Elapsed time is 0.001346 seconds. M_out = 1 16 9 6 2 4 11 10 3 12 15 5 13 14 7 8

2   Pass
%% seed=clock; seed=1000*seed(6); rng(seed) n=8; % Create a Unique element square array M=randperm(n*n); M=reshape(M,n,n) vr=M(1:n,:); vr=sortrows(vr); vc=M(:,1:n); vc=sortrows(vc')'; tic M_out=Criss_Cross(vr,vc); toc M_out assert(isequal(M,M_out));

M = 6 25 31 10 29 43 59 14 47 48 38 46 50 49 26 1 16 20 24 62 44 42 40 34 2 32 22 54 15 19 4 13 11 64 33 21 5 27 17 18 39 23 41 7 8 55 57 28 9 30 12 56 45 51 52 53 37 35 36 61 3 58 60 63 Elapsed time is 0.000106 seconds. M_out = 6 25 31 10 29 43 59 14 47 48 38 46 50 49 26 1 16 20 24 62 44 42 40 34 2 32 22 54 15 19 4 13 11 64 33 21 5 27 17 18 39 23 41 7 8 55 57 28 9 30 12 56 45 51 52 53 37 35 36 61 3 58 60 63

3   Pass
%% seed=clock; seed=1000*seed(6); rng(seed) n=128; % Create a Unique element square array M=randperm(n*n); M=reshape(M,n,n); vr=M(1:n,:); vr=sortrows(vr); vc=M(:,1:n); vc=sortrows(vc')'; tic M_out=Criss_Cross(vr,vc); toc assert(isequal(M,M_out));

Elapsed time is 0.001310 seconds.

4   Pass
%% seed=clock; seed=1000*seed(6); rng(seed) n=1024; % Create a Unique element square array M=randperm(n*n); M=reshape(M,n,n); vr=M(1:n,:); vr=sortrows(vr); vc=M(:,1:n); vc=sortrows(vc')'; tic M_out=Criss_Cross(vr,vc); toc assert(isequal(M,M_out));

Elapsed time is 0.041987 seconds.

5   Pass
%% seed=clock; seed=1000*seed(6); rng(seed) n=4096; % Create a Unique element square array M=randperm(n*n); M=reshape(M,n,n); vr=M(1:n,:); vr=sortrows(vr); vc=M(:,1:n); vc=sortrows(vc')'; tic M_out=Criss_Cross(vr,vc); toc assert(isequal(M,M_out));

Elapsed time is 0.960476 seconds.