Cody

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

Solution 1958791

Submitted on 4 Oct 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|)')) )

temp = 1 2 3 4 5 y = 1 2 3 4 5

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

temp = 7 8 9 temp = 10 11 12 temp = 13 14 15 y = 7 8 9 10 11 12 13 14 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|)')) )

temp = 13 14 15 temp = 7 8 9 y = 13 14 15 7 8 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|)')) )

temp = 1 2 3 4 temp = 6 7 8 9 temp = 11 12 13 14 temp = 16 17 18 19 temp = 21 22 23 24 temp = 26 27 28 29 temp = 31 32 33 34 temp = 36 37 38 39 temp = 41 42 43 44 temp = 46 47 48 49 temp = 51 52 53 54 temp = 56 57 58 59 temp = 61 62 63 64 temp = 66 67 68 69 temp = 71 72 73 74 temp = 76 77 78 79 temp = 81 82 83 84 temp = 86 87 88 89 temp = 91 92 93 94 temp = 96 97 98 99 temp = 101 102 103 104 temp = 106 107 108 109 temp = 111 112 113 114 temp = 116 117 118 119 temp = 121 122 123 124 temp = 126 127 128 129 temp = 131 132 133 134 temp = 136 137 138 139 temp = 141 142 143 144 temp = 146 147 148 149 temp = 151 152 153 154 temp = 156 157 158 159 temp = 161 162 163 164 temp = 166 167 168 169 temp = 171 172 173 174 temp = 176 177 178 179 temp = 181 182 183 184 temp = 186 187 188 189 temp = 191 192 193 194 temp = 196 197 198 199 temp = 201 202 203 204 temp = 206 207 208 209 temp = 211 212 213 214 temp = 216 217 218 219 temp = 221 222 223 224 temp = 226 227 228 229 temp = 231 232 233 234 temp = 236 237 238 239 temp = 241 242 243 244 temp = 246 247 248 249 temp = 251 252 253 254 temp = 256 257 258 259 temp = 261 262 263 264 temp = 266 267 268 269 temp = 271 272 273 274 temp = 276 277 278 279 temp = 281 282 283 284 temp = 286 287 288 289 temp = 291 292 293 294 temp = 296 297 298 299 temp = 301 302 303 304 temp = 306 307 308 309 temp = 311 312 313 314 temp = 316 317 318 319 temp = 321 322 323 324 temp = 326 327 328 329 temp = 331 332 333 334 temp = 336 337 338 339 temp = 341 342 343 344 temp = 346 347 348 349 temp = 351 352 353 354 temp = 356 357 358 359 temp = 361 362 363 364 temp = 366 367 368 369 temp = 371 372 373 374 temp = 376 377 378 379 temp = 381 382 383 384 temp = 386 387 388 389 temp = 391 392 393 394 temp = 396 397 398 399 temp = 401 402 403 404 temp = 406 407 408 409 temp = 411 412 413 414 temp = 416 417 418 419 temp = 421 422 423 424 temp = 426 427 428 429 temp = 431 432 433 434 temp = 436 437 438 439 temp = 441 442 443 444 temp = 446 447 448 449 temp = 451 452 453 454 temp = 456 457 458 459 temp = 461 462 463 464 temp = 466 467 468 469 temp = 471 472 473 474 temp = 476 477 478 479 temp = 481 482 483 484 temp = 486 487 488 489 temp = 491 492 493 494 temp = 496 497 498 499 temp = 501 502 503 504 temp = 506 507 508 509 temp = 511 512 513 514 temp = 516 517 518 519 temp = 521 522 523 524 temp = 526 527 528 529 temp = 531 532 533 534 temp = 536 537 538 539 temp = 541 542 543 544 temp = 546 547 548 549 temp = 551 552 553 554 temp = 556 557 558 559 temp = 561 562 563 564 temp = 566 567 568 569 temp = 571 572 573 574 temp = 576 577 578 579 temp = 581 582 583 584 temp = 586 587 588 589 temp = 591 592 593 594 temp = 596 597 598 599 temp = 601 602 603 604 temp = 606 607 608 609 temp = 611 612 613 614 temp = 616 617 618 619 temp = 621 622 623 624 temp = 626 627 628 629 temp = 631 632 633 634 temp = 636 637 638 639 temp = 641 642 643 644 temp = 646 647 648 649 temp = 651 652 653 654 temp = 656 657 658 659 temp = 661 662 663 664 temp = 666 667 668 669 temp = 671 672 673 674 temp = 676 677 678 679 temp = 681 682 683 684 temp = 686 687 688 689 temp = 691 692 693 694 temp = 696 697 698 699 temp = 701 702 703 704 temp = 706 707 708 709 temp = 711 712 713 714 temp = 716 717 718 719 temp = 721 722 723 724 temp = 726 727 728 729 temp = 731 732 733 734 temp = 736 737 738 739 temp = 741 742 743 744 temp = 746 747 748 749 temp = 751 752 753 754 temp = 756 757 758 759 temp = 761 762 763 764 temp = 766 767 768 769 temp = 771 772 773 774 temp = 776 777 778 779 temp = 781 782 783 784 temp = 786 787 788 789 temp = 791 792 793 794 temp = 796 797 798 799 temp = 801 802 803 804 temp = 806 807 808 809 temp = 811 812 813 814 temp = 816 817 818 819 temp = 821 822 823 824 temp = 826 827 828 829 temp = 831 832 833 834 temp = 836 837 838 839 temp = 841 842 843 844 temp = 846 847 848 849 temp = 851 852 853 854 temp = 856 857 858 859 temp = 861 862 863 864 temp = 866 867 868 869 temp = 871 872 873 874 temp = 876 877 878 879 temp = 881 882 883 884 temp = 886 887 888 889 temp = 891 892 893 894 temp = 896 897 898 899 temp = 901 902 903 904 temp = 906 907 908 909 temp = 911 912 913 914 temp = 916 917 918 919 temp = 921 922 923 924 temp = 926 927 928 929 temp = 931 932 933 934 temp = 936 937 938 939 temp = 941 942 943 944 temp = 946 947 948 949 temp = 951 952 953 954 temp = 956 957 958 959 temp = 961 962 963 964 temp = 966 967 968 969 temp = 971 972 973 974 temp = 976 977 978 979 temp = 981 982 983 984 temp = 986 987 988 989 temp = 991 992 993 994 temp = 996 997 998 999 temp = 1001 1002 1003 1004 temp = 1006 1007 1008 1009 temp = 1011 1012 1013 1014 temp = 1016 1017 1018 1019 temp = 1021 1022 1023 1024 temp = 1026 1027 1028 1029 temp = 1031 1032 1033 1034 temp = 1036 1037 1038 1039 temp = 1041 1042 1043 1044 temp = 1046 1047 1048 1049 temp = 1051 1052 1053 1054 temp = 1056 1057 1058 1059 temp = 1061 1062 1063 1064 temp = 1066 1067 1068 1069 temp = 1071 1072 1073 1074 temp = 1076 1077 1078 1079 temp = 1081 1082 1083 1084 temp = 1086 1087 1088 1089 temp = 1091 1092 1093 1094 temp = 1096 1097 1098 1099 temp = 1101 1102 1103 1104 temp = 1106 1107 1108 1109 temp = 1111 1112 1113 1114 temp = 1116 1117 1118 1119 temp = 1121 1122 1123 1124 temp = 1126 1127 1128 1129 temp = 1131 1132 1133 1134 temp = 1136 1137 1138 1139 temp = 1141 1142 1143 1144 temp = 1146 1147 1148 1149 temp = 1151 1152 1153 1154 temp = 1156 1157 1158 1159 temp = 1161 1162 1163 1164 temp = 1166 1167 1168 1169 temp = 1171 1172 1173 1174 temp = 1176 1177 1178 1179 temp = 1181 1182 1183 1184 temp = 1186 1187 1188 1189 temp = 1191 1192 1193 1194 temp = 1196 1197 1198 1199 temp = 1201 1202 1203 1204 temp = 1206 1207 1208 1209 temp = 1211 1212 1213 1214 temp = 1216 1217 1218 1219 temp = 1221 1222 1223 1224 temp = 1226 1227 1228 1229 temp = 1231 1232 1233 1234 temp = 1236 1237 1238 1239 temp = 1241 1242 1243 1244 temp = 1246 1247 1248 1249 temp = 1251 1252 1253 ...

Assertion failed.