Cody

# Problem 364. Matrix spiral

Solution 2122983

Submitted on 9 Feb 2020
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   Fail
n = 1; y_correct =[0]; assert(isequal(Matrix_Spiral(n),y_correct))

Matrix index is out of range for deletion. Error in Matrix_Spiral (line 6) A(:,1)=[]; Error in Test1 (line 3) assert(isequal(Matrix_Spiral(n),y_correct))

2   Fail
n = 2; y_correct =[11 11 0 0]; assert(isequal(Matrix_Spiral(n),y_correct))

A = 1×0 empty double row vector

Assertion failed.

3   Fail
n = 3; y_correct =[11 11 11 0 0 11 0 0 0]; assert(isequal(Matrix_Spiral(n),y_correct))

A = 7 8

Assertion failed.

4   Fail
n = 4; y_correct =[11 11 11 11 0 0 0 11 0 0 11 11 0 0 0 0]; assert(isequal(Matrix_Spiral(n),y_correct))

A = 9 13 10 14 11 15

Assertion failed.

5   Fail
n = 5; y_correct =[11 11 11 11 11 0 0 0 0 11 0 0 11 0 11 0 0 11 11 11 0 0 0 0 0]; assert(isequal(Matrix_Spiral(n),y_correct))

A = 11 16 21 12 17 22 13 18 23 14 19 24

Assertion failed.

6   Fail
n = 10; y_correct =[11 11 11 11 11 11 11 11 11 11 0 0 0 0 0 0 0 0 0 11 0 0 11 11 11 11 11 11 0 11 0 0 11 0 0 0 0 11 0 11 0 0 11 0 11 11 0 11 0 11 0 0 11 0 11 0 0 11 0 11 0 0 11 0 11 11 11 11 0 11 0 0 11 0 0 0 0 0 0 11 0 0 11 11 11 11 11 11 11 11 0 0 0 0 0 0 0 0 0 0]; assert(isequal(Matrix_Spiral(n),y_correct))

A = 21 31 41 51 61 71 81 91 22 32 42 52 62 72 82 92 23 33 43 53 63 73 83 93 24 34 44 54 64 74 84 94 25 35 45 55 65 75 85 95 26 36 46 56 66 76 86 96 27 37 47 57 67 77 87 97 28 38 48 58 68 78 88 98 29 39 49 59 69 79 89 99

Assertion failed.

7   Fail
n = 17; y_correct =[11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 0 0 11 11 11 11 11 11 11 11 11 11 11 11 11 0 11 0 0 11 0 0 0 0 0 0 0 0 0 0 0 11 0 11 0 0 11 0 11 11 11 11 11 11 11 11 11 0 11 0 11 0 0 11 0 11 0 0 0 0 0 0 0 11 0 11 0 11 0 0 11 0 11 0 11 11 11 11 11 0 11 0 11 0 11 0 0 11 0 11 0 11 0 0 0 11 0 11 0 11 0 11 0 0 11 0 11 0 11 0 11 0 11 0 11 0 11 0 11 0 0 11 0 11 0 11 0 11 11 11 0 11 0 11 0 11 0 0 11 0 11 0 11 0 0 0 0 0 11 0 11 0 11 0 0 11 0 11 0 11 11 11 11 11 11 11 0 11 0 11 0 0 11 0 11 0 0 0 0 0 0 0 0 0 11 0 11 0 0 11 0 11 11 11 11 11 11 11 11 11 11 11 0 11 0 0 11 0 0 0 0 0 0 0 0 0 0 0 0 0 11 0 0 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; assert(isequal(Matrix_Spiral(n),y_correct))

A = 35 52 69 86 103 120 137 154 171 188 205 222 239 256 273 36 53 70 87 104 121 138 155 172 189 206 223 240 257 274 37 54 71 88 105 122 139 156 173 190 207 224 241 258 275 38 55 72 89 106 123 140 157 174 191 208 225 242 259 276 39 56 73 90 107 124 141 158 175 192 209 226 243 260 277 40 57 74 91 108 125 142 159 176 193 210 227 244 261 278 41 58 75 92 109 126 143 160 177 194 211 228 245 262 279 42 59 76 93 110 127 144 161 178 195 212 229 246 263 280 43 60 77 94 111 128 145 162 179 196 213 230 247 264 281 44 61 78 95 112 129 146 163 180 197 214 231 248 265 282 45 62 79 96 113 130 147 164 181 198 215 232 249 266 283 46 63 80 97 114 131 148 165 182 199 216 233 250 267 284 47 64 81 98 115 132 149 166 183 200 217 234 251 268 285 48 65 82 99 116 133 150 167 184 201 218 235 252 269 286 49 66 83 100 117 134 151 168 185 202 219 236 253 270 287 50 67 84 101 118 135 152 169 186 203 220 237 254 271 288

Assertion failed.