Cody

# Problem 6. Select every other element of a vector

Solution 2007000

Submitted on 7 Nov 2019 by Charlton Newell
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))

n = 0.1013 n = 0.1013 0.0367 n = 0.1013 0.0367 0.8503 n = 0.1013 0.0367 0.8503 0.3572 n = 0.1013 0.0367 0.8503 0.3572 0.4093

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

n = 0.4978 n = 0.4978 0.6490 n = 0.4978 0.6490 0.9836 n = 0.4978 0.6490 0.9836 0.3291 n = 0.4978 0.6490 0.9836 0.3291 0.3126 n = 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 n = 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 n = 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 n = 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 n = 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 n = 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 n = 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 n = 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 n = 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 n = 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 n = 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 n = 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 n = 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Column 19 0.6852 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 20 0.6852 0.0044 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 21 0.6852 0.0044 0.0365 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 22 0.6852 0.0044 0.0365 0.7049 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 23 0.6852 0.0044 0.0365 0.7049 0.3768 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 24 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 25 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 26 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 27 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 0.3174 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 28 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 0.3174 0.7638 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 29 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 0.3174 0.7638 0.8092 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 30 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 0.3174 0.7638 0.8092 0.0685 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 31 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 0.3174 0.7638 0.8092 0.0685 0.0432 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 32 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 0.3174 0.7638 0.8092 0.0685 0.0432 0.8517 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 33 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 0.3174 0.7638 0.8092 0.0685 0.0432 0.8517 0.0789 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 34 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 0.3174 0.7638 0.8092 0.0685 0.0432 0.8517 0.0789 0.7627 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 35 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 0.3174 0.7638 0.8092 0.0685 0.0432 0.8517 0.0789 0.7627 0.5395 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 36 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 0.3174 0.7638 0.8092 0.0685 0.0432 0.8517 0.0789 0.7627 0.5395 0.9285 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 36 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 0.3174 0.7638 0.8092 0.0685 0.0432 0.8517 0.0789 0.7627 0.5395 0.9285 Column 37 0.4874 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 36 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 0.3174 0.7638 0.8092 0.0685 0.0432 0.8517 0.0789 0.7627 0.5395 0.9285 Columns 37 through 38 0.4874 0.4991 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 36 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 0.3174 0.7638 0.8092 0.0685 0.0432 0.8517 0.0789 0.7627 0.5395 0.9285 Columns 37 through 39 0.4874 0.4991 0.6117 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 36 0.6852 0.0044 0.0365 0.7049 0.3768 0.8624 0.1460 0.1459 0.3174 0.7638 0.8092 0.0685 0.0432 0.8517 0.0789 0.7627 0.5395 0.9285 Columns 37 through 40 0.4874 0.4991 0.6117 0.0523 n = Columns 1 through 18 0.4978 0.6490 0.9836 0.3291 0.3126 0.2653 0.9836 0.8748 0.1215 0.7379 0.4479 0.5588 0.4687 0.6189 0.3299 0.2145 0.6102 0.0255 Columns 19 through 36 0.6852 0.0044 0.0365 0.70...

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

n = 65 n = 65 111 n = 65 111 103 n = 65 111 103 105 n = 65 111 103 105 101 n = 65 111 103 105 101 103 n = 65 111 103 105 101 103 105 n = 65 111 103 105 101 103 105 97 n = 65 111 103 105 101 103 105 97 97 n = 65 111 103 105 101 103 105 97 97 97 n = 65 111 103 105 101 103 105 97 97 97 121 n = 65 111 103 105 101 103 105 97 97 97 121 97 n = 65 111 103 105 101 103 105 97 97 97 121 97 102 n = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 n = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 119 n = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 119 121