Cody

# Problem 737. Criss_Cross_000 : Unique elements in a Square array

Solution 1564511

Submitted on 19 Jun 2018 by J. S. Kowontan
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 = 13 8 9 15 10 6 12 3 16 4 14 7 2 5 11 1 Elapsed time is 0.023336 seconds. M_out = 13 8 9 15 10 6 12 3 16 4 14 7 2 5 11 1

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

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.007691 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.233130 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 5.424037 seconds.