Cody

# Problem 6. Select every other element of a vector

Solution 1874034

Submitted on 15 Jul 2019 by Brandon Suit
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))

AA = 1 A = 10 y = 0.8251 y = 0.8251 0.9372 y = 0.8251 0.9372 0.5188 y = 0.8251 0.9372 0.5188 0.9790 y = 0.8251 0.9372 0.5188 0.9790 0.1116

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

AA = 1 A = 100 y = 0.3968 y = 0.3968 0.6592 y = 0.3968 0.6592 0.4021 y = 0.3968 0.6592 0.4021 0.1774 y = 0.3968 0.6592 0.4021 0.1774 0.7942 y = 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 y = 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 y = 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 y = 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 y = 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 y = 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 y = 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 y = 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 y = 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 y = 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 y = 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 y = 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 y = 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Column 19 0.5396 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 20 0.5396 0.3339 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 21 0.5396 0.3339 0.0995 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 22 0.5396 0.3339 0.0995 0.8666 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 23 0.5396 0.3339 0.0995 0.8666 0.1310 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 24 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 25 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 26 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 27 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 0.8981 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 28 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 0.8981 0.4668 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 29 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 0.8981 0.4668 0.4173 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 30 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 0.8981 0.4668 0.4173 0.3403 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 31 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 0.8981 0.4668 0.4173 0.3403 0.0870 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 32 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 0.8981 0.4668 0.4173 0.3403 0.0870 0.0517 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 33 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 0.8981 0.4668 0.4173 0.3403 0.0870 0.0517 0.8922 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 34 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 0.8981 0.4668 0.4173 0.3403 0.0870 0.0517 0.8922 0.1861 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 35 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 0.8981 0.4668 0.4173 0.3403 0.0870 0.0517 0.8922 0.1861 0.9026 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 36 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 0.8981 0.4668 0.4173 0.3403 0.0870 0.0517 0.8922 0.1861 0.9026 0.1351 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 36 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 0.8981 0.4668 0.4173 0.3403 0.0870 0.0517 0.8922 0.1861 0.9026 0.1351 Column 37 0.4241 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 36 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 0.8981 0.4668 0.4173 0.3403 0.0870 0.0517 0.8922 0.1861 0.9026 0.1351 Columns 37 through 38 0.4241 0.8481 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 36 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 0.8981 0.4668 0.4173 0.3403 0.0870 0.0517 0.8922 0.1861 0.9026 0.1351 Columns 37 through 39 0.4241 0.8481 0.2844 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 36 0.5396 0.3339 0.0995 0.8666 0.1310 0.6123 0.4788 0.4333 0.8981 0.4668 0.4173 0.3403 0.0870 0.0517 0.8922 0.1861 0.9026 0.1351 Columns 37 through 40 0.4241 0.8481 0.2844 0.8584 y = Columns 1 through 18 0.3968 0.6592 0.4021 0.1774 0.7942 0.4075 0.9055 0.8805 0.9753 0.7401 0.5889 0.3595 0.0977 0.2901 0.4722 0.3715 0.7972 0.8508 Columns 19 through 36 0.539...

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

AA = 1 A = 31 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'