Cody

# Problem 6. Select every other element of a vector

Solution 1792491

Submitted on 18 Apr 2019 by jiaqi wang
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.8072 y = 0.8072 0.0034 y = 0.8072 0.0034 0.3239 y = 0.8072 0.0034 0.3239 0.5331 y = 0.8072 0.0034 0.3239 0.5331 0.5420

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

y = 0.6525 y = 0.6525 0.2258 y = 0.6525 0.2258 0.4789 y = 0.6525 0.2258 0.4789 0.1557 y = 0.6525 0.2258 0.4789 0.1557 0.4565 y = 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 y = 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 y = 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 y = 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 y = 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 y = 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 y = 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 y = 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 y = 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 y = 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 y = 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 y = 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 y = 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Column 19 0.2004 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 20 0.2004 0.6797 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 21 0.2004 0.6797 0.1197 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 22 0.2004 0.6797 0.1197 0.1728 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 23 0.2004 0.6797 0.1197 0.1728 0.4962 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 24 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 25 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 26 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 27 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 0.2756 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 28 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 0.2756 0.4359 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 29 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 0.2756 0.4359 0.9130 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 30 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 0.2756 0.4359 0.9130 0.4962 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 31 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 0.2756 0.4359 0.9130 0.4962 0.2531 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 32 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 0.2756 0.4359 0.9130 0.4962 0.2531 0.2904 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 33 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 0.2756 0.4359 0.9130 0.4962 0.2531 0.2904 0.0556 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 34 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 0.2756 0.4359 0.9130 0.4962 0.2531 0.2904 0.0556 0.0629 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 35 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 0.2756 0.4359 0.9130 0.4962 0.2531 0.2904 0.0556 0.0629 0.8354 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 36 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 0.2756 0.4359 0.9130 0.4962 0.2531 0.2904 0.0556 0.0629 0.8354 0.1804 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 36 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 0.2756 0.4359 0.9130 0.4962 0.2531 0.2904 0.0556 0.0629 0.8354 0.1804 Column 37 0.9807 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 36 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 0.2756 0.4359 0.9130 0.4962 0.2531 0.2904 0.0556 0.0629 0.8354 0.1804 Columns 37 through 38 0.9807 0.0605 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 36 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 0.2756 0.4359 0.9130 0.4962 0.2531 0.2904 0.0556 0.0629 0.8354 0.1804 Columns 37 through 39 0.9807 0.0605 0.7334 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 36 0.2004 0.6797 0.1197 0.1728 0.4962 0.6013 0.0027 0.0567 0.2756 0.4359 0.9130 0.4962 0.2531 0.2904 0.0556 0.0629 0.8354 0.1804 Columns 37 through 40 0.9807 0.0605 0.7334 0.1935 y = Columns 1 through 18 0.6525 0.2258 0.4789 0.1557 0.4565 0.6646 0.7367 0.4799 0.2052 0.6991 0.8785 0.4401 0.6229 0.6480 0.9472 0.8939 0.8247 0.8967 Columns 19 through 36 0.2004 0.6797 0.1197 0.17...

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'