Cody

Problem 45578. Create a matrix that counts up diagonally

Solution 2363288

Submitted on 25 May 2020 by bainhome
  • Size: 36
  • 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
N = 20; mx_correct = [... 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 2 5 9 14 20 27 35 44 54 65 77 90 104 119 135 152 170 189 209 229 4 8 13 19 26 34 43 53 64 76 89 103 118 134 151 169 188 208 228 247 7 12 18 25 33 42 52 63 75 88 102 117 133 150 168 187 207 227 246 264 11 17 24 32 41 51 62 74 87 101 116 132 149 167 186 206 226 245 263 280 16 23 31 40 50 61 73 86 100 115 131 148 166 185 205 225 244 262 279 295 22 30 39 49 60 72 85 99 114 130 147 165 184 204 224 243 261 278 294 309 29 38 48 59 71 84 98 113 129 146 164 183 203 223 242 260 277 293 308 322 37 47 58 70 83 97 112 128 145 163 182 202 222 241 259 276 292 307 321 334 46 57 69 82 96 111 127 144 162 181 201 221 240 258 275 291 306 320 333 345 56 68 81 95 110 126 143 161 180 200 220 239 257 274 290 305 319 332 344 355 67 80 94 109 125 142 160 179 199 219 238 256 273 289 304 318 331 343 354 364 79 93 108 124 141 159 178 198 218 237 255 272 288 303 317 330 342 353 363 372 92 107 123 140 158 177 197 217 236 254 271 287 302 316 329 341 352 362 371 379 106 122 139 157 176 196 216 235 253 270 286 301 315 328 340 351 361 370 378 385 121 138 156 175 195 215 234 252 269 285 300 314 327 339 350 360 369 377 384 390 137 155 174 194 214 233 251 268 284 299 313 326 338 349 359 368 376 383 389 394 154 173 193 213 232 250 267 283 298 312 325 337 348 358 367 375 382 388 393 397 172 192 212 231 249 266 282 297 311 324 336 347 357 366 374 381 387 392 396 399 191 211 230 248 265 281 296 310 323 335 346 356 365 373 380 386 391 395 398 400 ]; assert(isequal(not_hankel(N),mx_correct))

2   Pass
N = 3; mx_correct = [... 1 3 6 2 5 8 4 7 9 ]; assert(isequal(not_hankel(N),mx_correct))

3   Pass
rng('shuffle') N = randi(99)+5; r = repmat((0:(N-1))',1,N) + (0:(N-1)); p = ((.5.*r.^2 + .5.*r) + (r(1,:)+1)); q = rot90(hankel(fliplr(0:N-1)),2).^2; mx_correct = p - q; assert(isequal(not_hankel(N),mx_correct))

4   Pass
N = 2; mx_correct =... [... 1 3 2 4 ]; assert(isequal(not_hankel(N),mx_correct))

Suggested Problems

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!