Cody

# Problem 6. Select every other element of a vector

Solution 2019239

Submitted on 14 Nov 2019 by Steven Butler
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.1545 j = 2 y = 0.1545 0.9942 j = 3 y = 0.1545 0.9942 0.1671 j = 4 y = 0.1545 0.9942 0.1671 0.9593 j = 5 y = 0.1545 0.9942 0.1671 0.9593 0.0527 j = 6

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

j = 1 y = 0.5252 j = 2 y = 0.5252 0.4397 j = 3 y = 0.5252 0.4397 0.5556 j = 4 y = 0.5252 0.4397 0.5556 0.1705 j = 5 y = 0.5252 0.4397 0.5556 0.1705 0.6671 j = 6 y = 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 j = 7 y = 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 j = 8 y = 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 j = 9 y = 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 j = 10 y = 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 j = 11 y = 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 j = 12 y = 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 j = 13 y = 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 j = 14 y = 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 j = 15 y = 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 j = 16 y = 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 j = 17 y = 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 j = 18 y = 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 j = 19 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Column 19 0.0991 j = 20 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 20 0.0991 0.8242 j = 21 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 21 0.0991 0.8242 0.1206 j = 22 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 22 0.0991 0.8242 0.1206 0.0152 j = 23 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 23 0.0991 0.8242 0.1206 0.0152 0.6385 j = 24 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 24 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 j = 25 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 25 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 j = 26 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 26 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 0.0986 j = 27 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 27 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 0.0986 0.4945 j = 28 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 28 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 0.0986 0.4945 0.2919 j = 29 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 29 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 0.0986 0.4945 0.2919 0.8647 j = 30 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 30 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 0.0986 0.4945 0.2919 0.8647 0.9886 j = 31 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 31 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 0.0986 0.4945 0.2919 0.8647 0.9886 0.0674 j = 32 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 32 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 0.0986 0.4945 0.2919 0.8647 0.9886 0.0674 0.0167 j = 33 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 33 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 0.0986 0.4945 0.2919 0.8647 0.9886 0.0674 0.0167 0.0935 j = 34 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 34 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 0.0986 0.4945 0.2919 0.8647 0.9886 0.0674 0.0167 0.0935 0.8672 j = 35 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 35 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 0.0986 0.4945 0.2919 0.8647 0.9886 0.0674 0.0167 0.0935 0.8672 0.9863 j = 36 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 36 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 0.0986 0.4945 0.2919 0.8647 0.9886 0.0674 0.0167 0.0935 0.8672 0.9863 0.2130 j = 37 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 36 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 0.0986 0.4945 0.2919 0.8647 0.9886 0.0674 0.0167 0.0935 0.8672 0.9863 0.2130 Column 37 0.5432 j = 38 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 36 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 0.0986 0.4945 0.2919 0.8647 0.9886 0.0674 0.0167 0.0935 0.8672 0.9863 0.2130 Columns 37 through 38 0.5432 0.3822 j = 39 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 0.8907 Columns 19 through 36 0.0991 0.8242 0.1206 0.0152 0.6385 0.6288 0.4354 0.0986 0.4945 0.2919 0.8647 0.9886 0.0674 0.0167 0.0935 0.8672 0.9863 0.2130 Columns 37 through 39 0.5432 0.3822 0.8703 j = 40 y = Columns 1 through 18 0.5252 0.4397 0.5556 0.1705 0.6671 0.6225 0.5850 0.5536 0.8339 0.2632 0.3551 0.8539 0.1036 0.8872 0.6164 0.5747 0.2255 ...

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' j = 17