Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 363209

Submitted on 3 Dec 2013 by Alfonso Nieto-Castanon

Correct

32Size
Leading solution size is 30.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
c=[ 20 33 12 4  ;
    16 1  31 21 ;
    23 13 19 4 ;
    10 22 7  30 ;
    9  9  9  9  ;
    2  18 25 34 ;
    29 26 11 3  ;
    32 17 5  15 ;
    6  8  28 27 ];
y_correct = 0;
assert(isequal(ismagic0(c),y_correct))

                    
2
Pass
 
%%
c=[ 20 33 12 4  ;
    16 1  31 21 ;
    23 13 19 14 ;
    10 22 7  30 ;
    9  9  9  9  ;
    2  18 25 24 ;
    29 26 11 3  ;
    32 17 5  15 ;
    6  8  28 27 ];
y_correct = 1;
assert(isequal(ismagic0(c),y_correct))

                    
3
Pass
 
%%
c=[24 10 23 16;
    25 22 13 1;
    18 7  19 31;
    2  30 14 21;
    9  9  9  9;
    4  6  32 29;
    12 8  17 26;
    33 28 5  11;
    20 27 15 3];
y_correct = 1;
assert(isequal(ismagic0(c),y_correct))

                    
4
Pass
 
%%
c=[ 30 29  2 32;
    7  18 26 17;
    22 25 11 5;
    10 24 3  15;
    9  9  9  9;
    27 20 16 23;
    28 33 1  13;
    8  12 31 19;
    6  4  21 14];
y_correct = 0;
assert(isequal(ismagic0(c),y_correct))

                    
5
Pass
 
%%
c=[30 2  29 32;
    7  18 26 17;
    22 25 11 5;
    10 24 16  15;
    9  9  9  9;
    27 20 3 23;
    28 33 1  13;
    8  12 31 19;
    6  4  21 14];
y_correct = 1;
assert(isequal(ismagic0(c),y_correct))

                    
6
Pass
 
%%
c=[30 2  29 32;
    7  18 26 17;
    22 25 11 5;
    10 24 3  15;
    9  9  9  9;
    27 20 16 23;
    28 33 1  13;
    8  12 31 19;
    6  4  21 14];
y_correct = 1;
assert(isequal(ismagic0(c),y_correct))

                    
7
Pass
 
%%
c=[ 30 2  29 32;
    22 25 11 4;
    7  18 26 17;
    9  23 2  15;
    8  9  9  10;
    28 21 17 23;
    8  12 31 19;
    29 33 1  13;
    6  4  21 14];
y_correct = 0;
assert(isequal(ismagic0(c),y_correct))

                    
8
Pass
 
%%
c=[ 20 34 11  4  ;
    16 0  31 21 ;
    23 13 19 14 ;
    10 22 7  30 ;
    9  9  9  9  ;
    2  18 25 24 ;
    29 26 11 3  ;
    32 17 6  15 ;
    6  8  28 27 ];
y_correct = 0;
assert(isequal(ismagic0(c),y_correct))

                    
9
Pass
 
%%
c=randi(32,9,4);
y_correct = 0;
assert(isequal(ismagic0(c),y_correct))