Cody

Problem 6. Select every other element of a vector

Solution 2060225

Submitted on 17 Dec 2019 by Maciej Pietrzak
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.7686 0.1732 0.4497 0.1762 0.1149

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

y = Columns 1 through 17 0.5826 0.0762 0.7937 0.3390 0.0004 0.5393 0.6671 0.3656 0.8529 0.2912 0.7697 0.6364 0.2326 0.2898 0.8445 0.4460 0.7432 Columns 18 through 34 0.4725 0.2183 0.7171 0.1722 0.8860 0.9264 0.6680 0.2542 0.1898 0.4487 0.3893 0.4277 0.2212 0.2804 0.1757 0.6201 0.1463 Columns 35 through 50 0.4946 0.9572 0.3590 0.9846 0.6754 0.5167 0.4848 0.7318 0.0776 0.7212 0.9721 0.7832 0.1093 0.0442 0.3252 0.8937

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'