Cody

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

Solution 2050449

Submitted on 8 Dec 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   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|)')) )

a = 1 5 b = 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|)')) )

a = 7 10 13 9 12 15 b = 7 8 9 10 11 12 13 14 15

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

a = 13 7 15 9 b = 1×0 empty double row vector

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

a = Columns 1 through 14 1 6 11 16 21 26 31 36 41 46 51 56 61 66 4 9 14 19 24 29 34 39 44 49 54 59 64 69 Columns 15 through 28 71 76 81 86 91 96 101 106 111 116 121 126 131 136 74 79 84 89 94 99 104 109 114 119 124 129 134 139 Columns 29 through 42 141 146 151 156 161 166 171 176 181 186 191 196 201 206 144 149 154 159 164 169 174 179 184 189 194 199 204 209 Columns 43 through 56 211 216 221 226 231 236 241 246 251 256 261 266 271 276 214 219 224 229 234 239 244 249 254 259 264 269 274 279 Columns 57 through 70 281 286 291 296 301 306 311 316 321 326 331 336 341 346 284 289 294 299 304 309 314 319 324 329 334 339 344 349 Columns 71 through 84 351 356 361 366 371 376 381 386 391 396 401 406 411 416 354 359 364 369 374 379 384 389 394 399 404 409 414 419 Columns 85 through 98 421 426 431 436 441 446 451 456 461 466 471 476 481 486 424 429 434 439 444 449 454 459 464 469 474 479 484 489 Columns 99 through 112 491 496 501 506 511 516 521 526 531 536 541 546 551 556 494 499 504 509 514 519 524 529 534 539 544 549 554 559 Columns 113 through 126 561 566 571 576 581 586 591 596 601 606 611 616 621 626 564 569 574 579 584 589 594 599 604 609 614 619 624 629 Columns 127 through 140 631 636 641 646 651 656 661 666 671 676 681 686 691 696 634 639 644 649 654 659 664 669 674 679 684 689 694 699 Columns 141 through 154 701 706 711 716 721 726 731 736 741 746 751 756 761 766 704 709 714 719 724 729 734 739 744 749 754 759 764 769 Columns 155 through 168 771 776 781 786 791 796 801 806 811 816 821 826 831 836 774 779 784 789 794 799 804 809 814 819 824 829 834 839 Columns 169 through 182 841 846 851 856 861 866 871 876 881 886 891 896 901 906 844 849 854 859 864 869 874 879 884 889 894 899 904 909 Columns 183 through 196 911 916 921 926 931 936 941 946 951 956 961 966 971 976 914 919 924 929 934 939 944 949 954 959 964 969 974 979 Columns 197 through 210 981 986 991 996 1001 1006 1011 1016 1021 1026 1031 1036 1041 1046 984 989 994 999 1004 1009 1014 1019 1024 1029 1034 1039 1044 1049 Columns 211 through 224 1051 1056 1061 1066 1071 1076 1081 1086 1091 1096 1101 1106 1111 1116 1054 1059 1064 1069 1074 1079 1084 1089 1094 1099 1104 1109 1114 1119 Columns 225 through 238 1121 1126 1131 1136 1141 1146 1151 1156 1161 1166 1171 1176 1181 1186 1124 1129 1134 1139 1144 1149 1154 1159 1164 1169 1174 1179 1184 1189 Columns 239 through 252 1191 1196 1201 1206 1211 1216 1221 1226 1231 1236 1241 1246 1251 1256 1194 1199 1204 1209 1214 1219 1224 1229 1234 1239 1244 1249 1254 1259 Columns 253 through 266 1261 1266 1271 1276 1281 1286 1291 1296 1301 1306 1311 1316 1321 1326 1264 1269 1274 1279 1284 1289 1294 1299 1304 1309 1314 1319 1324 1329 Columns 267 through 280 1331 1336 1341 1346 1351 1356 1361 1366 1371 1376 1381 1386 1391 1396 1334 1339 1344 1349 1354 1359 1364 1369 1374 1379 1384 1389 1394 1399 Columns 281 through 294 1401 1406 1411 1416 1421 1426 1431 1436 1441 1446 1451 1456 1461 1466 1404 1409 1414 1419 1424 1429 1434 1439 1444 1449 1454 1459 1464 1469 Columns 295 through 308 1471 1476 1481 1486 1491 1496 1501 1506 1511 1516 1521 1526 1531 1536 1474 1479 1484 1489 1494 1499 1504 1509 1514 1519 1524 1529 1534 1539 Columns 309 through 322 1541 1546 1551 1556 1561 1566 1571 1576 1581 1586 1591 1596 1601 1606 1544 1549 1554 1559 1564 1569 1574 1579 1584 1589 1594 1599 1604 1609 Columns 323 through 336 1611 1616 1621 1626 1631 1636 1641 1646 1651 1656 1661 1666 1671 1676 1614 1619 1624 1629 1634 1639 1644 1649 1654 1659 1664 1669 1674 1679 Columns 337 through 350 1681 1686 1691 1696 1701 1706 1711 1716 1721 1726 1731 1736 1741 1746 1684 1689 1694 1699 1704 1709 1714 1719 1724 1729 1734 1739 1744 1749 Columns 351 through 364 1751 1756 1761 1766 1771 1776 1781 1786 1791 1796 1801 1806 1811 1816 1754 1759 1764 1769 1774 1779 1784 1789 1794 1799 1804 1809 1814 1819 Columns 365 through 378 1821 1826 1831 1836 1841 1846 1851 1856 1861 1866 1871 1876 1881 1886 1824 1829 1834 1839 1844 1849 1854 1859 1864 1869 1874 1879 1884 1889 Columns 379 through 392 1891 1896 1901 1906 1911 1916 1921 1926 ...

Assertion failed.