Cody

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

Solution 1958790

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 y = 7 8 9 temp = 10 11 12 y = 7 8 9 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 y = 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 y = 1 2 3 4 temp = 6 7 8 9 y = 1 2 3 4 6 7 8 9 temp = 11 12 13 14 y = 1 2 3 4 6 7 8 9 11 12 13 14 temp = 16 17 18 19 y = 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 temp = 21 22 23 24 y = 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 temp = 26 27 28 29 y = 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 temp = 31 32 33 34 y = 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 temp = 36 37 38 39 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 32 38 39 temp = 41 42 43 44 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 36 38 39 41 42 43 44 temp = 46 47 48 49 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 40 38 39 41 42 43 44 46 47 48 49 temp = 51 52 53 54 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 44 38 39 41 42 43 44 46 47 48 49 51 52 53 54 temp = 56 57 58 59 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 48 38 39 41 42 43 44 46 47 48 49 51 52 53 54 56 57 58 59 temp = 61 62 63 64 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 52 38 39 41 42 43 44 46 47 48 49 51 52 53 54 56 57 58 59 61 62 63 64 temp = 66 67 68 69 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 56 38 39 41 42 43 44 46 47 48 49 51 52 53 54 56 57 58 59 61 62 63 64 66 67 68 69 temp = 71 72 73 74 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 60 38 39 41 42 43 44 46 47 48 49 51 52 53 54 56 57 58 59 61 62 63 64 66 67 68 69 71 72 73 74 temp = 76 77 78 79 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 60 38 39 41 42 43 44 46 47 48 49 51 52 53 54 56 57 58 59 61 62 63 64 66 67 68 69 71 72 73 74 Columns 61 through 64 76 77 78 79 temp = 81 82 83 84 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 60 38 39 41 42 43 44 46 47 48 49 51 52 53 54 56 57 58 59 61 62 63 64 66 67 68 69 71 72 73 74 Columns 61 through 68 76 77 78 79 81 82 83 84 temp = 86 87 88 89 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 60 38 39 41 42 43 44 46 47 48 49 51 52 53 54 56 57 58 59 61 62 63 64 66 67 68 69 71 72 73 74 Columns 61 through 72 76 77 78 79 81 82 83 84 86 87 88 89 temp = 91 92 93 94 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 60 38 39 41 42 43 44 46 47 48 49 51 52 53 54 56 57 58 59 61 62 63 64 66 67 68 69 71 72 73 74 Columns 61 through 76 76 77 78 79 81 82 83 84 86 87 88 89 91 92 93 94 temp = 96 97 98 99 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 60 38 39 41 42 43 44 46 47 48 49 51 52 53 54 56 57 58 59 61 62 63 64 66 67 68 69 71 72 73 74 Columns 61 through 80 76 77 78 79 81 82 83 84 86 87 88 89 91 92 93 94 96 97 98 99 temp = 101 102 103 104 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 60 38 39 41 42 43 44 46 47 48 49 51 52 53 54 56 57 58 59 61 62 63 64 66 67 68 69 71 72 73 74 Columns 61 through 84 76 77 78 79 81 82 83 84 86 87 88 89 91 92 93 94 96 97 98 99 101 102 103 104 temp = 106 107 108 109 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 60 38 39 41 42 43 44 46 47 48 49 51 52 53 54 56 57 58 59 61 62 63 64 66 67 68 69 71 72 73 74 Columns 61 through 88 76 77 78 79 81 82 83 84 86 87 88 89 91 92 93 94 96 97 98 99 101 102 103 104 106 107 108 109 temp = 111 112 113 114 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 60 38 39 41 42 43 44 46 47 48 49 51 52 53 54 56 57 58 59 61 62 63 64 66 67 68 69 71 72 73 74 Columns 61 through 90 76 77 78 79 81 82 83 84 86 87 88 89 91 92 93 94 96 97 98 99 101 102 103 104 106 107 108 109 111 112 Columns 91 through 92 113 114 temp = 116 117 118 119 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 60 38 39 41 42 43 44 46 47 48 49 51 52 53 54 56 57 58 59 61 62 63 64 66 67 68 69 71 72 73 74 Columns 61 through 90 76 77 78 79 81 82 83 84 86 87 88 89 91 92 93 94 96 97 98 99 101 102 103 104 106 107 108 109 111 112 Columns 91 through 96 113 114 116 117 118 119 temp = 121 122 123 124 y = Columns 1 through 30 1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 Columns 31 through 60 38 39 41 42 43 44 46 47 48 49 51 52 53 54 56 57 58 59 61 62 63 64 66 67 68 69 71 72 73 74 Columns 61 through 90 76 77 78 79 81 82 83 84 86 87 88 89 91 92 93 94 96 97 98 99 101...

Assertion failed.