Cody

Solution 107805

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