Cody

Solution 109733

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