Cody

Problem 6. Select every other element of a vector

Solution 1848175

Submitted on 13 Jun 2019 by Chirag Nighut
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.9177 0.7152 0.7042 0.6016 0.8569

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

y = Columns 1 through 18 0.3813 0.6781 0.1221 0.5641 0.9563 0.4109 0.0258 0.9347 0.6890 0.1479 0.2370 0.4650 0.7245 0.0700 0.5646 0.5176 0.5232 0.6929 Columns 19 through 36 0.4288 0.0642 0.7748 0.6110 0.0892 0.8358 0.6614 0.2861 0.6220 0.6972 0.1940 0.6662 0.8950 0.0593 0.9389 0.7063 0.7732 0.0555 Columns 37 through 50 0.3483 0.6356 0.0854 0.5164 0.1616 0.8888 0.3799 0.7034 0.3176 0.8630 0.6351 0.1733 0.4270 0.0854

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 = 'Aogiegiaaayafrwy'