Cody

# Problem 801. Construct an index vector from two input vectors in vectorized fashion

Solution 1943232

Submitted on 19 Sep 2019
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
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|)')) )

steps = 4 M = 1.0000 2.3333 3.6667 5.0000 ans = 1.0000 2.3333 3.6667 5.0000

Assertion failed.

2   Fail
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|)')) )

steps = 2 M = 7 9 10 12 13 15 ans = 7 10 13 9 12 15

Assertion failed.

3   Fail
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|)')) )

steps = 2 M = 13 15 7 9 ans = 13 7 15 9

Assertion failed.

4   Fail
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|)')) )

steps = 3 M = 1.0e+03 * 0.0010 0.0025 0.0040 0.0060 0.0075 0.0090 0.0110 0.0125 0.0140 0.0160 0.0175 0.0190 0.0210 0.0225 0.0240 0.0260 0.0275 0.0290 0.0310 0.0325 0.0340 0.0360 0.0375 0.0390 0.0410 0.0425 0.0440 0.0460 0.0475 0.0490 0.0510 0.0525 0.0540 0.0560 0.0575 0.0590 0.0610 0.0625 0.0640 0.0660 0.0675 0.0690 0.0710 0.0725 0.0740 0.0760 0.0775 0.0790 0.0810 0.0825 0.0840 0.0860 0.0875 0.0890 0.0910 0.0925 0.0940 0.0960 0.0975 0.0990 0.1010 0.1025 0.1040 0.1060 0.1075 0.1090 0.1110 0.1125 0.1140 0.1160 0.1175 0.1190 0.1210 0.1225 0.1240 0.1260 0.1275 0.1290 0.1310 0.1325 0.1340 0.1360 0.1375 0.1390 0.1410 0.1425 0.1440 0.1460 0.1475 0.1490 0.1510 0.1525 0.1540 0.1560 0.1575 0.1590 0.1610 0.1625 0.1640 0.1660 0.1675 0.1690 0.1710 0.1725 0.1740 0.1760 0.1775 0.1790 0.1810 0.1825 0.1840 0.1860 0.1875 0.1890 0.1910 0.1925 0.1940 0.1960 0.1975 0.1990 0.2010 0.2025 0.2040 0.2060 0.2075 0.2090 0.2110 0.2125 0.2140 0.2160 0.2175 0.2190 0.2210 0.2225 0.2240 0.2260 0.2275 0.2290 0.2310 0.2325 0.2340 0.2360 0.2375 0.2390 0.2410 0.2425 0.2440 0.2460 0.2475 0.2490 0.2510 0.2525 0.2540 0.2560 0.2575 0.2590 0.2610 0.2625 0.2640 0.2660 0.2675 0.2690 0.2710 0.2725 0.2740 0.2760 0.2775 0.2790 0.2810 0.2825 0.2840 0.2860 0.2875 0.2890 0.2910 0.2925 0.2940 0.2960 0.2975 0.2990 0.3010 0.3025 0.3040 0.3060 0.3075 0.3090 0.3110 0.3125 0.3140 0.3160 0.3175 0.3190 0.3210 0.3225 0.3240 0.3260 0.3275 0.3290 0.3310 0.3325 0.3340 0.3360 0.3375 0.3390 0.3410 0.3425 0.3440 0.3460 0.3475 0.3490 0.3510 0.3525 0.3540 0.3560 0.3575 0.3590 0.3610 0.3625 0.3640 0.3660 0.3675 0.3690 0.3710 0.3725 0.3740 0.3760 0.3775 0.3790 0.3810 0.3825 0.3840 0.3860 0.3875 0.3890 0.3910 0.3925 0.3940 0.3960 0.3975 0.3990 0.4010 0.4025 0.4040 0.4060 0.4075 0.4090 0.4110 0.4125 0.4140 0.4160 0.4175 0.4190 0.4210 0.4225 0.4240 0.4260 0.4275 0.4290 0.4310 0.4325 0.4340 0.4360 0.4375 0.4390 0.4410 0.4425 0.4440 0.4460 0.4475 0.4490 0.4510 0.4525 0.4540 0.4560 0.4575 0.4590 0.4610 0.4625 0.4640 0.4660 0.4675 0.4690 0.4710 0.4725 0.4740 0.4760 0.4775 0.4790 0.4810 0.4825 0.4840 0.4860 0.4875 0.4890 0.4910 0.4925 0.4940 0.4960 0.4975 0.4990 0.5010 0.5025 0.5040 0.5060 0.5075 0.5090 0.5110 0.5125 0.5140 0.5160 0.5175 0.5190 0.5210 0.5225 0.5240 0.5260 0.5275 0.5290 0.5310 0.5325 0.5340 0.5360 0.5375 0.5390 0.5410 0.5425 0.5440 0.5460 0.5475 0.5490 0.5510 0.5525 0.5540 0.5560 0.5575 0.5590 0.5610 0.5625 0.5640 0.5660 0.5675 0.5690 0.5710 0.5725 0.5740 0.5760 0.5775 0.5790 0.5810 0.5825 0.5840 0.5860 0.5875 0.5890 0.5910 0.5925 0.5940 0.5960 0.5975 0.5990 0.6010 0.6025 0.6040 0.6060 0.6075 0.6090 0.6110 0.6125 0.6140 0.6160 0.6175 0.6190 0.6210 0.6225 0.6240 0.6260 0.6275 0.6290 0.6310 0.6325 0.6340 0.6360 0.6375 0.6390 0.6410 0.6425 0.6440 0.6460 0.6475 0.6490 0.6510 0.6525 0.6540 0.6560 0.6575 0.6590 0.6610 0.6625 0.6640 0.6660 0.6675 0.6690 0.6710 0.6725 0.6740 0.6760 0.6775 0.6790 0.6810 0.6825 0.6840 0.6860 0.6875 0.6890 0.6910 0.6925 0.6940 0.6960 0.6975 0.6990 0.7010 0.7025 0.7040 0.7060 0.7075 0.7090 0.7110 0.7125 0.7140 0.7160 0.7175 0.7190 0.7210 0.7225 0.7240 0.7260 0.7275 0.7290 0.7310 0.7325 0.7340 0.7360 0.7375 0.7390 0.7410 0.7425 0.7440 0.7460 0.7475 0.7490 0.7510 0.7525 0.7540 0.7560 0.7575 0.7590 0.7610 0.7625 0.7640 0.7660 0.7675 0.7690 0.7710 0.7725 0.7740 0.7760 0.7775 0.7790 0.7810 0.7825 0.7840 0.7860 0.7875 0.7890 0.7910 0.7925 0.7940 0.7960 0.7975 0.7990 0.8010 0.8025 0.8040 0.8060 0.8075 0.8090 0.8110 0.8125 0.8140 0.8160 0.8175 0.8190 0.8210 0.8225 0.8240 0.8260 0.8275 0.8290 0.8310 0.8325 0.8340 0.8360 0.8375 0.8390 0.8410 0.8425 0.8440 0.8460 0.8475 0.8490 0.8510 0.8525 0.8540 0.8560 0.8575 0.8590 0.8610 0.8625 0.8640 0.8660 0.8675 0.8690 0.8710 0.8725 0.8740 0.8760 0.8775 0.8790 0.8810 0.8825 0.8840 0.8860 0.8875 0.8890 0.8910 0.8925 0.8940 0.8960 0.8975 0.8990 0.9010 0.9025 0.9040 0.9060 0.9075 0.9090 0.9110 0.9125 0.9140 0.9160 0.9175 0.9190 0.9210 0.9225 0.9240 0.9260 0.9275 0.9290 0.9310 0.9325 0.9340 0.9360 0.9375 0.9390 0.9410 0.9425 0.9440 0.9460 0.9475 0.9490 0.9510 0.9525 0.9540 0.9560 0.9575 0.9590 0.9610 0.9625 0.9640 0.9660 0.9675 0.9690 0.9710 0.9725 0.9740 0.9760 0.9775 0.9790 0.9810 0.9825 0.9840 0.9860 0.9875 0.9890 0.9910 0.9925 0.9940 0.9960 0.9975 0.9990 1.0010 1.0025 1.0040 1.0060 1.0075 1.0090 1.0110 1.0125 1.0140 1.0160 1.0175 1.0190 1.0210 1.0225 1.0240 1.0260 1.0275 1.0290 1.0310 1.0325 1.0340 1.0360 1.0375 1.0390 1.0410 1.0425 1.0440 1.0460 1.0475 1.0490 1.0510 1.0525 1.0540 1.0560 1.0575 1.0590 1.0610 1.0625 1.0640 1.0660 1.0675 1.0690 1.0710 1.0725 1.0740 1.0760 1.0775 1.0790 1.0810 1.0825 1.0840 1.0860 1.0875 1.0890 1.0910 1.0925 1.0940 1.0960 1.0975 1.0990 1.1010 1.1025 1.1040 1.1060 1.1075 1.1090 1.1110 1.1125 1.1140 1.1160 1.1175 1.1190 1.1210 1.1225 1.1240 1.1260 1.1275 1.1290 1.1310 1.1325 1.1340 1.1360 1.1375 1.1390 1.1410 1.1425 1.1440 1.1460 1.1475 1.1490 1.1510 1.1525 1.1540 1.1560 1.1575 1.1590 1.1610 1.1625 1.1640 1.1660 1.1675 1.1690 1.1710 1.1725 1.1740 1.1760 1.1775 1.1790 1.1810 1.1825 1.1840 1.1860 1.1875 1.1890 1.1910 1.1925 1.1940 1.1960 1.1975 1.1990 1.2010 1.2025 1.2040 1.2060 1.2075 1.2090 1.2110 1.2125 1.2140 1.2160 1.2175 1.2190 1.2210 1.2225 1.2240 1.2260 1.2275 1.2290 1.2310 1.2325 1.2340 1.2360 1.2375 1.2390 1.2410 1.2425 1.2440 1.2460 1.2475 1.2490 1.2510 1.2525 1.2540 1.2560 1.2575 1.2590 1.2610 1.2625 1.2640 1.2660 1.2675 1.2690 1.2710 1.2725 1.2740 1.2760 1.2775 1.2790 1.2810 1.2825 1.2840 1.2860 1.2875 1.2890 1.2910 1.2925 1.2940 1.2960 1.2975 1.2990 1.3010 1.3025 1.3040 1.3060 1.3075 1.3090 1.3110 1.3125 1.3140 1.3160 1.3175 1.3190 1.3210 1.3225 1.3240 1.3260 1.3275 1.3290 1.3310 1.3325 1.3340 1.3360 1.3375 1.3390 1.3410 1.3425 1.3440 1.3460 1.3475 1.3490 1.3510 1.3525 1.3540 1.3560 1.3575 1.3590 1.3610 1.3625 1.3640 1.3660 1.3675 1.3690 1.3710 1.3725 1.3740 1.3760 1.3775 1.3790 1.3810 1.3825 1.3840 1.3860 1.3875 1.3890 1.3910 1.3925 1.3940 1.3960 1.3975 1.3990 1.4010 1.4025 1.4040 1.4060 1.4075 1.4090 1.4110 1.4125 1.4140 1.4160 1.4175 1.4190 1.4210 1.4225 1.4240 1.4260 1.4275 1.4290 1.4310 1.4325 1.4340 1.4360 1.4375 1.4390 1.4410 1.4425 1.4440 1.4460 1.4475 1.4490 1.4510 1.4525 1.4540 1.4560 1.4575 1.4590 1.4610 1.4625 1.4640 1.4660 1.4675 1.4690 1.4710 1.4725 1.4740 1.4760 1.4775 1.4790 1.4810 1.4825 1.4840 1.4860 1.4875 1.4890 1.4910 1.4925 1.4940 1.4960 1.4975 1.4990 1.5010 1.5025 1.5040 1.5060 1.5075 1.5090 1.5110 1.5125 1.5140 1.5160 1.5175 1.5190 1.5210 1.5225 1.5240 1.5260 1.5275 1.5290 1.5310 1.5325 1.5340 1.5360 1.5375 1.5390 1.5410 1.5425 1.5440 1.5460 1.5475 1.5490 1.5510 1.5525 1.5540 1.5560 1.5575 1.5590 1.5610 1.5625 1.5640 1.5660 1.5675 1.5690 1.5710 1.5725 1.5740 1.5760 1.5775 1.5790 1.5810 1.5825 1.5840 1.5860 1.5875 1.5890 1.5910 1.5925 1.5940 1.5960 1.5975 1.5990 1.6010 1.6025 1.6040 1.6060 ...

Assertion failed.