Cody

Solution 1671177

Submitted on 10 Nov 2018 by William
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 12 10 16 14 9 4 8 11 6 3 7 5 13 15 2 Elapsed time is 0.006578 seconds. M_out = 1 12 10 16 14 9 4 8 11 6 3 7 5 13 15 2

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

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.002620 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.165909 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 2.962325 seconds.