Cody

# Problem 6. Select every other element of a vector

Solution 1744409

Submitted on 7 Mar 2019 by Yaphet Elias
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))

y = 0.4855 y = 0.4855 0.3468 y = 0.4855 0.3468 0.7392 y = 0.4855 0.3468 0.7392 0.4186 y = 0.4855 0.3468 0.7392 0.4186 0.4677

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

y = 0.2687 y = 0.2687 0.2162 y = 0.2687 0.2162 0.0756 y = 0.2687 0.2162 0.0756 0.4465 y = 0.2687 0.2162 0.0756 0.4465 0.5811 y = 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 y = 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 y = 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 y = 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 y = 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 y = 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 y = 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 y = 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 y = 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 y = 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 y = 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 y = 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 y = 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Column 19 0.0288 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 20 0.0288 0.3507 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 21 0.0288 0.3507 0.5727 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 22 0.0288 0.3507 0.5727 0.0633 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 23 0.0288 0.3507 0.5727 0.0633 0.1522 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 24 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 25 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 26 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 27 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 0.0688 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 28 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 0.0688 0.3772 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 29 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 0.0688 0.3772 0.6285 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 30 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 0.0688 0.3772 0.6285 0.3652 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 31 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 0.0688 0.3772 0.6285 0.3652 0.2346 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 32 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 0.0688 0.3772 0.6285 0.3652 0.2346 0.6903 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 33 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 0.0688 0.3772 0.6285 0.3652 0.2346 0.6903 0.1596 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 34 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 0.0688 0.3772 0.6285 0.3652 0.2346 0.6903 0.1596 0.1736 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 35 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 0.0688 0.3772 0.6285 0.3652 0.2346 0.6903 0.1596 0.1736 0.4990 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 36 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 0.0688 0.3772 0.6285 0.3652 0.2346 0.6903 0.1596 0.1736 0.4990 0.3607 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 36 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 0.0688 0.3772 0.6285 0.3652 0.2346 0.6903 0.1596 0.1736 0.4990 0.3607 Column 37 0.9845 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 36 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 0.0688 0.3772 0.6285 0.3652 0.2346 0.6903 0.1596 0.1736 0.4990 0.3607 Columns 37 through 38 0.9845 0.8065 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 36 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 0.0688 0.3772 0.6285 0.3652 0.2346 0.6903 0.1596 0.1736 0.4990 0.3607 Columns 37 through 39 0.9845 0.8065 0.0043 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 36 0.0288 0.3507 0.5727 0.0633 0.1522 0.9166 0.0678 0.6427 0.0688 0.3772 0.6285 0.3652 0.2346 0.6903 0.1596 0.1736 0.4990 0.3607 Columns 37 through 40 0.9845 0.8065 0.0043 0.3711 y = Columns 1 through 18 0.2687 0.2162 0.0756 0.4465 0.5811 0.3047 0.9429 0.1610 0.6274 0.2997 0.0292 0.0065 0.8219 0.8943 0.5482 0.9946 0.6704 0.5500 Columns 19 through 36 0.0288 0.3507 0.5727 0.06...

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

y = 'A' y = 'Ao' y = 'Aog' y = 'Aogi' y = 'Aogie' y = 'Aogieg' y = 'Aogiegi' y = 'Aogiegia' y = 'Aogiegiaa' y = 'Aogiegiaaa' y = 'Aogiegiaaay' y = 'Aogiegiaaaya' y = 'Aogiegiaaayaf' y = 'Aogiegiaaayafr' y = 'Aogiegiaaayafrw' y = 'Aogiegiaaayafrwy'