Cody

# Problem 6. Select every other element of a vector

Solution 1505255

Submitted on 26 Apr 2018 by Matthew Trappett
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
x = rand(1,10); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

r = 10 p = [] p = 0.6572 p = 0.6572 0.4869 p = 0.6572 0.4869 0.7955 p = 0.6572 0.4869 0.7955 0.5540 p = 0.6572 0.4869 0.7955 0.5540 0.5074 y = 0.6572 0.4869 0.7955 0.5540 0.5074

2   Pass
x = rand(1,100); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

r = 100 p = [] p = 0.9670 p = 0.9670 0.0662 p = 0.9670 0.0662 0.1960 p = 0.9670 0.0662 0.1960 0.0971 p = 0.9670 0.0662 0.1960 0.0971 0.4212 p = 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 p = 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 p = 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 p = 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 p = 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 p = 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 p = 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 p = 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 p = 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 p = 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 p = 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 p = 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 p = 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Column 19 0.2441 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 20 0.2441 0.0748 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 21 0.2441 0.0748 0.4471 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 22 0.2441 0.0748 0.4471 0.1013 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 23 0.2441 0.0748 0.4471 0.1013 0.1229 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 24 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 25 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 26 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 27 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 0.5812 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 28 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 0.5812 0.3422 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 29 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 0.5812 0.3422 0.0824 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 30 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 0.5812 0.3422 0.0824 0.4342 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 31 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 0.5812 0.3422 0.0824 0.4342 0.1688 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 32 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 0.5812 0.3422 0.0824 0.4342 0.1688 0.1481 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 33 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 0.5812 0.3422 0.0824 0.4342 0.1688 0.1481 0.3846 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 34 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 0.5812 0.3422 0.0824 0.4342 0.1688 0.1481 0.3846 0.0943 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 35 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 0.5812 0.3422 0.0824 0.4342 0.1688 0.1481 0.3846 0.0943 0.6398 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 36 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 0.5812 0.3422 0.0824 0.4342 0.1688 0.1481 0.3846 0.0943 0.6398 0.5004 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 36 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 0.5812 0.3422 0.0824 0.4342 0.1688 0.1481 0.3846 0.0943 0.6398 0.5004 Column 37 0.4375 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 36 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 0.5812 0.3422 0.0824 0.4342 0.1688 0.1481 0.3846 0.0943 0.6398 0.5004 Columns 37 through 38 0.4375 0.4035 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 36 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 0.5812 0.3422 0.0824 0.4342 0.1688 0.1481 0.3846 0.0943 0.6398 0.5004 Columns 37 through 39 0.4375 0.4035 0.8189 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 36 0.2441 0.0748 0.4471 0.1013 0.1229 0.6625 0.4894 0.5358 0.5812 0.3422 0.0824 0.4342 0.1688 0.1481 0.3846 0.0943 0.6398 0.5004 Columns 37 through 40 0.4375 0.4035 0.8189 0.8221 p = Columns 1 through 18 0.9670 0.0662 0.1960 0.0971 0.4212 0.8556 0.7188 0.9526 0.4006 0.7924 0.5787 0.7645 0.5508 0.0806 0.1720 0.6540 0.1220 0.6794 Columns 19 through 36 0.244...

3   Pass
x = ['A' 'long' 'time' 'ago' 'in' 'a' 'galaxy' 'far' 'far' 'away']; actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

r = 31 p = [] p = 65 p = 65 111 p = 65 111 103 p = 65 111 103 105 p = 65 111 103 105 101 p = 65 111 103 105 101 103 p = 65 111 103 105 101 103 105 p = 65 111 103 105 101 103 105 97 p = 65 111 103 105 101 103 105 97 97 p = 65 111 103 105 101 103 105 97 97 97 p = 65 111 103 105 101 103 105 97 97 97 121 p = 65 111 103 105 101 103 105 97 97 97 121 97 p = 65 111 103 105 101 103 105 97 97 97 121 97 102 p = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 p = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 119 p = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 119 121 y = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 119 121