Cody

# Problem 6. Select every other element of a vector

Solution 2143975

Submitted on 28 Feb 2020 by Henry Wu
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.3888 y = 0.3888 0.7868 y = 0.3888 0.7868 0.4827 y = 0.3888 0.7868 0.4827 0.4419 y = 0.3888 0.7868 0.4827 0.4419 0.6853

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

y = 0.2842 y = 0.2842 0.4828 y = 0.2842 0.4828 0.8976 y = 0.2842 0.4828 0.8976 0.5708 y = 0.2842 0.4828 0.8976 0.5708 0.6263 y = 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 y = 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 y = 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 y = 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 y = 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 y = 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 y = 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 y = 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 y = 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 y = 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 y = 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 y = 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Column 18 0.1079 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 19 0.1079 0.9944 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 20 0.1079 0.9944 0.1380 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 21 0.1079 0.9944 0.1380 0.8510 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 22 0.1079 0.9944 0.1380 0.8510 0.0918 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 23 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 24 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 25 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 26 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 27 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 0.0291 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 28 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 0.0291 0.4887 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 29 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 0.0291 0.4887 0.7103 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 30 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 0.0291 0.4887 0.7103 0.8311 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 31 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 0.0291 0.4887 0.7103 0.8311 0.9679 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 32 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 0.0291 0.4887 0.7103 0.8311 0.9679 0.9166 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 33 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 0.0291 0.4887 0.7103 0.8311 0.9679 0.9166 0.3692 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 34 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 0.0291 0.4887 0.7103 0.8311 0.9679 0.9166 0.3692 0.1302 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 34 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 0.0291 0.4887 0.7103 0.8311 0.9679 0.9166 0.3692 0.1302 Column 35 0.9589 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 34 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 0.0291 0.4887 0.7103 0.8311 0.9679 0.9166 0.3692 0.1302 Columns 35 through 36 0.9589 0.4888 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 34 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 0.0291 0.4887 0.7103 0.8311 0.9679 0.9166 0.3692 0.1302 Columns 35 through 37 0.9589 0.4888 0.8539 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 34 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 0.0291 0.4887 0.7103 0.8311 0.9679 0.9166 0.3692 0.1302 Columns 35 through 38 0.9589 0.4888 0.8539 0.5106 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 34 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 0.0291 0.4887 0.7103 0.8311 0.9679 0.9166 0.3692 0.1302 Columns 35 through 39 0.9589 0.4888 0.8539 0.5106 0.8143 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911 0.6492 0.1543 0.0070 Columns 18 through 34 0.1079 0.9944 0.1380 0.8510 0.0918 0.4080 0.5786 0.5749 0.2389 0.0291 0.4887 0.7103 0.8311 0.9679 0.9166 0.3692 0.1302 Columns 35 through 40 0.9589 0.4888 0.8539 0.5106 0.8143 0.8401 y = Columns 1 through 17 0.2842 0.4828 0.8976 0.5708 0.6263 0.2900 0.5868 0.8257 0.2619 0.4833 0.7865 0.7662 0.2054 0.3911...

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'