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

Correct

42Size
Leading solution size is 18.
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
 
%%
x1 = 1; x2 = 5;
y_correct = [1:5];
assert(isequal(interleaved_idx(x1,x2),y_correct) && isempty(regexp(evalc('type interleaved_idx'),'(eval|for|while|)')) )
ans =
     1     2     3     4     5
2
Pass
 
%%
x1 = [7 10 13]; x2 = [9 12 15];
y_correct = [7:15];
assert(isequal(interleaved_idx(x1,x2),y_correct) && isempty(regexp(evalc('type interleaved_idx'),'(eval|for|while|)')) )
ans =
     7     8     9    10    11    12    13    14    15
3
Pass
 
%%
x1 = [13 7]; x2 = [15 9];
y_correct = [13 14 15 7 8 9];
assert(isequal(interleaved_idx(x1,x2),y_correct) && isempty(regexp(evalc('type interleaved_idx'),'(eval|for|while|)')) )
ans =
    13    14    15     7     8     9
4
Pass
 
%%
x1=[1:5:5000];x2=[4:5:5000];y_correct=setdiff([1:5000],[5:5:5000]);
assert( isequal(interleaved_idx(x1,x2),y_correct) && isempty(regexp(evalc('type interleaved_idx'),'(eval|for|while|)')) )
ans =
  Columns 1 through 5
           1           2           3           4           6
  Columns 6 through 10
           7           8           9          11          12
  Columns 11 through 15
          13          14          16          17          18
  Columns 16 through 20
          19          21          22          23          24
  Columns 21 through 25
          26          27          28          29          31
  Columns 26 through 30
          32          33          34          36          37
  Columns 31 through 35
          38          39          41          42          43
  Columns 36 through 40
          44          46          47          48          49
  Columns 41 through 45
          51          52          53          54          56
  Columns 46 through 50
          57          58          59          61          62
  Columns 51 through 55
          63          64          66          67          68
  Columns 56 through 60
          69          71          72          73          74
  Columns 61 through 65
          76          77          78          79          81
  Columns 66 through 70
          82          83          84          86          87
  Columns 71 through 75
          88          89          91          92          93
  Columns 76 through 80
          94          96          97          98          99
  Columns 81 through 85
         101         102         103         104         106
  Columns 86 through 90
         107         108         109         111         112
  Columns 91 through 95
         113         114         116         117         118
  Columns 96 through 100
         119         121         122         123         124
  Columns 101 through 105
         126         127         128         129         131
  Columns 106 through 110
         132         133         134         136         137
  Columns 111 through 115
         138         139         141         142         143
  Columns 116 through 120
         144         146         147         148         149
  Columns 121 through 125
         151         152         153         154         156
  Columns 126 through 130
         157         158         159         161         162
  Columns 131 through 135
         163         164         166         167         168
  Columns 136 through 140
         169         171         172         173         174
  Columns 141 through 145
         176         177         178         179         181
  Columns 146 through 150
         182         183         184         186         187
  Columns 151 through 155
         188         189         191         192         193
  Columns 156 through 160
         194         196         197         198         199
  Columns 161 through 165
         201         202         203         204         206
  Columns 166 through 170
         207         208         209         211         212
  Columns 171 through 175
         213         214         216         217         218
  Columns 176 through 180
         219         221         222         223         224
  Columns 181 through 185
         226         227         228         229         231
  Columns 186 through 190
         232         233         234         236         237
  Columns 191 through 195
         238         239         241         242         243
  Columns 196 through 200
         244         246         247         248         249
  Columns 201 through 205
         251         252         253         254         256
  Columns 206 through 210
         257         258         259         261         262
  Columns 211 through 215
         263         264         266         267         268
  Columns 216 through 220
         269         271         272         273         274
  Columns 221 through 225
         276         277         278         279         281
  Columns 226 through 230
         282         283         284         286         287
  Columns 231 through 235
         288         289         291         292         293
  Columns 236 through 240
         294         296         297         298         299
  Columns 241 through 245
         301         302         303         304         306
  Columns 246 through 250
         307         308         309         311         312
  Columns 251 through 255
         313         314         316         317         318
  Columns 256 through 260
         319         321         322         323         324
  Columns 261 through 265
         326         327         328         329         331
  Columns 266 through 270
         332         333         334         336         337
  Columns 271 through 275
         338         339         341         342         343
  Columns 276 through 280
         344         346         347         348         349
  Columns 281 through 285
         351         352         353         354         356
  Columns 286 through 290
         357         358         359         361         362
  Columns 291 through 295
         363         364         366         367         368
  Columns 296 through 300
         369         371         372         373         374
  Columns 301 through 305
         376         377         378         379         381
  Columns 306 through 310
         382         383         384         386         387
  Columns 311 through 315
         388         389         391         392         393
  Columns 316 through 320
         394         396         397         398         399
  Columns 321 through 325
         401         402         403         404         406
  Columns 326 through 330
         407         408         409         411         412
  Columns 331 through 335
         413         414         416         417         418
  Columns 336 through 340
         419         421         422         423         424
  Columns 341 through 345
         426         427         428         429         431
  Columns 346 through 350
         432         433         434         436         437
  Columns 351 through 355
         438         439         441         442         443
  Columns 356 through 360
         444         446         447         448         449
  Columns 361 through 365
         451         452         453         454         456
  Columns 366 through 370
         457         458         459         461         462
  Columns 371 through 375
         463         464         466         467         468
  Columns 376 through 380
         469         471         472         473         474
  Columns 381 through 385
         476         477         478         479         481
  Columns 386 through 390
         482         483         484         486         487
  Columns 391 through 395
         488         489         491         492         493
  Columns 396 through 400
         494         496         497         498         499
  Columns 401 through 405
         501         502         503         504         506
  Columns 406 through 410
         507         508         509         511         512
  Columns 411 through 415
         513         514         516         517         518
  Columns 416 through 420
         519         521         522         523         524
  Columns 421 through 425
         526         527         528         529         531
  Columns 426 through 430
         532         533         534         536         537
  Columns 431 through 435
         538         539         541         542         543
  Columns 436 through 440
         544         546         547         548         549
  Columns 441 through 445
         551         552         553         554         556
  Columns 446 through 450
         557         558         559         561         562
  Columns 451 through 455
         563         564         566         567         568
  Columns 456 through 460
         569         571         572         573         574
  Columns 461 through 465
         576         577         578         579         581
  Columns 466 through 470
         582         583         584         586         587
  Columns 471 through 475
         588         589         591         592         593
  Columns 476 through 480
         594         596         597         598         599
  Columns 481 through 485
         601         602         603         604         606
  Columns 486 through 490
         607         608         609         611         612
  Columns 491 through 495
         613         614         616         617         618
  Columns 496 through 500
         619         621         622         623         624
  Columns 501 through 505
         626         627         628         629         631
  Columns 506 through 510
         632         633         634         636         637
  Columns 511 through 515
         638         639         641         642         643
  Columns 516 through 520
         644         646         647         648         649
  Columns 521 through 525
         651         652         653         654         656
  Columns 526 through 530
         657         658         659         661         662
  Columns 531 through 535
         663         664         666         667         668
  Columns 536 through 540
         669         671         672         673         674
  Columns 541 through 545
         676         677         678         679         681
  Columns 546 through 550
         682         683         684         686         687
  Columns 551 through 555
         688         689         691         692         693
  Columns 556 through 560
         694         696         697         698         699
  Columns 561 through 565
         701         702         703         704         706
  Columns 566 through 570
         707         708         709         711         712
  Columns 571 through 575
         713         714         716         717         718
  Columns 576 through 580
    ...