Cody

# Problem 6. Select every other element of a vector

Solution 1888976

Submitted on 31 Jul 2019 by Jacques Tott-buswell
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))

j = 1 y = 0.2675 j = 2 y = 0.2675 0.6924 j = 3 y = 0.2675 0.6924 0.8319 j = 4 y = 0.2675 0.6924 0.8319 0.5658 j = 5 y = 0.2675 0.6924 0.8319 0.5658 0.1946

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

j = 1 y = 0.3829 j = 2 y = 0.3829 0.4187 j = 3 y = 0.3829 0.4187 0.8397 j = 4 y = 0.3829 0.4187 0.8397 0.7520 j = 5 y = 0.3829 0.4187 0.8397 0.7520 0.6540 j = 6 y = 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 j = 7 y = 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 j = 8 y = 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 j = 9 y = 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 j = 10 y = 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 j = 11 y = 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 j = 12 y = 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 j = 13 y = 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 j = 14 y = 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 j = 15 y = 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 j = 16 y = 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 j = 17 y = 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 j = 18 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Column 18 0.5888 j = 19 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 19 0.5888 0.7917 j = 20 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 20 0.5888 0.7917 0.7562 j = 21 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 21 0.5888 0.7917 0.7562 0.5946 j = 22 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 22 0.5888 0.7917 0.7562 0.5946 0.1543 j = 23 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 23 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 j = 24 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 24 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 j = 25 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 25 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 j = 26 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 26 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 0.1664 j = 27 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 27 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 0.1664 0.2498 j = 28 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 28 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 0.1664 0.2498 0.1593 j = 29 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 29 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 0.1664 0.2498 0.1593 0.8579 j = 30 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 30 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 0.1664 0.2498 0.1593 0.8579 0.8063 j = 31 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 31 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 0.1664 0.2498 0.1593 0.8579 0.8063 0.5955 j = 32 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 32 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 0.1664 0.2498 0.1593 0.8579 0.8063 0.5955 0.3087 j = 33 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 33 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 0.1664 0.2498 0.1593 0.8579 0.8063 0.5955 0.3087 0.7225 j = 34 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 34 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 0.1664 0.2498 0.1593 0.8579 0.8063 0.5955 0.3087 0.7225 0.9680 j = 35 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 34 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 0.1664 0.2498 0.1593 0.8579 0.8063 0.5955 0.3087 0.7225 0.9680 Column 35 0.6725 j = 36 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 34 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 0.1664 0.2498 0.1593 0.8579 0.8063 0.5955 0.3087 0.7225 0.9680 Columns 35 through 36 0.6725 0.1544 j = 37 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 34 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 0.1664 0.2498 0.1593 0.8579 0.8063 0.5955 0.3087 0.7225 0.9680 Columns 35 through 37 0.6725 0.1544 0.7215 j = 38 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 34 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 0.1664 0.2498 0.1593 0.8579 0.8063 0.5955 0.3087 0.7225 0.9680 Columns 35 through 38 0.6725 0.1544 0.7215 0.8954 j = 39 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0.3386 0.2193 0.9461 0.9919 0.1648 0.1921 0.5321 0.5609 0.9616 0.0903 0.0829 Columns 18 through 34 0.5888 0.7917 0.7562 0.5946 0.1543 0.5812 0.2439 0.7525 0.1664 0.2498 0.1593 0.8579 0.8063 0.5955 0.3087 0.7225 0.9680 Columns 35 through 39 0.6725 0.1544 0.7215 0.8954 0.2819 j = 40 y = Columns 1 through 17 0.3829 0.4187 0.8397 0.7520 0.6540 0.2435 0....

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

j = 1 y = 'A' j = 2 y = 'Ao' j = 3 y = 'Aog' j = 4 y = 'Aogi' j = 5 y = 'Aogie' j = 6 y = 'Aogieg' j = 7 y = 'Aogiegi' j = 8 y = 'Aogiegia' j = 9 y = 'Aogiegiaa' j = 10 y = 'Aogiegiaaa' j = 11 y = 'Aogiegiaaay' j = 12 y = 'Aogiegiaaaya' j = 13 y = 'Aogiegiaaayaf' j = 14 y = 'Aogiegiaaayafr' j = 15 y = 'Aogiegiaaayafrw' j = 16 y = 'Aogiegiaaayafrwy'