Cody

# Problem 738. Criss_Cross_010 : Unique elements, Square array, Words in one array

Solution 172304

Submitted on 4 Dec 2012 by @bmtran
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,:); vc=M(:,1:n); w=[vr;vc']; w=sortrows(w); M_out=Criss_Cross(w) assert(isequal(M,M_out)||isequal(M',M_out));

```M = 14 3 13 8 6 1 12 16 11 7 9 2 5 4 10 15 M_out = 14 6 11 5 3 1 7 4 13 12 9 10 8 16 2 15 ```

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,:); vc=M(:,1:n); w=[vr;vc']; w=sortrows(w); M_out=Criss_Cross(w) assert(isequal(M,M_out)||isequal(M',M_out));

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

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

```Elapsed time is 0.000697 seconds. ```

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

```Elapsed time is 0.000255 seconds. ```

5   Pass
%% n=256; % Create a Unique element square array M=randperm(n*n); M=reshape(M,n,n); vr=M(1:n,:); vc=M(:,1:n); w=[vr;vc']; w=sortrows(w); tic M_out=Criss_Cross(w); toc assert(isequal(M,M_out)||isequal(M',M_out));

```Elapsed time is 0.000990 seconds. ```