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 403397

Submitted on 13 Feb 2014 by Mehmet OZC

Correct

65Size
Leading solution size is 12.
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
 
%%
X = [1 0 -1];
y_correct = -1;
assert(isequal(largest_territory(X),y_correct));
X =
     1
     0
    -1
2
Pass
 
%%
X = [1 1 1 2 2];
y_correct = 1;
assert(isequal(largest_territory(X),y_correct));
X =
     1
     1
     1
     2
     2
3
Pass
 
%%
X = [1 1 1 2 3; 1 1 1 2 3; 1 1 1 2 3; 1 1 2 2 2; 2 2 2 2 2];
y_correct = 1;
assert(isequal(largest_territory(X),y_correct));
X =
     1
     1
     1
     1
     2
     1
     1
     1
     1
     2
     1
     1
     1
     2
     2
     2
     2
     2
     2
     2
     3
     3
     3
     2
     2
4
Pass
 
%%
X = [1 1 1 1 1 1 1; 1 1 2 2 2 1 1; 1 1 2 2 2 1 1; 1 1 2 2 2 1 1; 1 1 2 2 1 1 1; 1 1 1 1 1 1 1; 3 3 3 3 3 3 3];
y_correct = 1;
assert(isequal(largest_territory(X),y_correct));
X =
     1
     1
     1
     1
     1
     1
     3
     1
     1
     1
     1
     1
     1
     3
     1
     2
     2
     2
     2
     1
     3
     1
     2
     2
     2
     2
     1
     3
     1
     2
     2
     2
     1
     1
     3
     1
     1
     1
     1
     1
     1
     3
     1
     1
     1
     1
     1
     1
     3
5
Pass
 
%%
X = [1:100; 101:150, 51:100; 101:175, 76:100; 101:190, 91:100];
y_correct = 91;
assert(isequal(largest_territory(X),y_correct));
X =
     1
   101
   101
   101
     2
   102
   102
   102
     3
   103
   103
   103
     4
   104
   104
   104
     5
   105
   105
   105
     6
   106
   106
   106
     7
   107
   107
   107
     8
   108
   108
   108
     9
   109
   109
   109
    10
   110
   110
   110
    11
   111
   111
   111
    12
   112
   112
   112
    13
   113
   113
   113
    14
   114
   114
   114
    15
   115
   115
   115
    16
   116
   116
   116
    17
   117
   117
   117
    18
   118
   118
   118
    19
   119
   119
   119
    20
   120
   120
   120
    21
   121
   121
   121
    22
   122
   122
   122
    23
   123
   123
   123
    24
   124
   124
   124
    25
   125
   125
   125
    26
   126
   126
   126
    27
   127
   127
   127
    28
   128
   128
   128
    29
   129
   129
   129
    30
   130
   130
   130
    31
   131
   131
   131
    32
   132
   132
   132
    33
   133
   133
   133
    34
   134
   134
   134
    35
   135
   135
   135
    36
   136
   136
   136
    37
   137
   137
   137
    38
   138
   138
   138
    39
   139
   139
   139
    40
   140
   140
   140
    41
   141
   141
   141
    42
   142
   142
   142
    43
   143
   143
   143
    44
   144
   144
   144
    45
   145
   145
   145
    46
   146
   146
   146
    47
   147
   147
   147
    48
   148
   148
   148
    49
   149
   149
   149
    50
   150
   150
   150
    51
    51
   151
   151
    52
    52
   152
   152
    53
    53
   153
   153
    54
    54
   154
   154
    55
    55
   155
   155
    56
    56
   156
   156
    57
    57
   157
   157
    58
    58
   158
   158
    59
    59
   159
   159
    60
    60
   160
   160
    61
    61
   161
   161
    62
    62
   162
   162
    63
    63
   163
   163
    64
    64
   164
   164
    65
    65
   165
   165
    66
    66
   166
   166
    67
    67
   167
   167
    68
    68
   168
   168
    69
    69
   169
   169
    70
    70
   170
   170
    71
    71
   171
   171
    72
    72
   172
   172
    73
    73
   173
   173
    74
    74
   174
   174
    75
    75
   175
   175
    76
    76
    76
   176
    77
    77
    77
   177
    78
    78
    78
   178
    79
    79
    79
   179
    80
    80
    80
   180
    81
    81
    81
   181
    82
    82
    82
   182
    83
    83
    83
   183
    84
    84
    84
   184
    85
    85
    85
   185
    86
    86
    86
   186
    87
    87
    87
   187
    88
    88
    88
   188
    89
    89
    89
   189
    90
    90
    90
   190
    91
    91
    91
    91
    92
    92
    92
    92
    93
    93
    93
    93
    94
    94
    94
    94
    95
    95
    95
    95
    96
    96
    96
    96
    97
    97
    97
    97
    98
    98
    98
    98
    99
    99
    99
    99
   100
   100
   100
   100