Cody

Problem 6. Select every other element of a vector

Solution 1712187

Submitted on 22 Jan 2019 by Casey Killeen
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.9350 0.3919 0.4806 0.8404 0.4563

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.6939 0.0635 0.1296 0.9662 0.5663 0.0379 0.2542 0.9242 0.6760 0.3677 0.6166 0.4453 0.4232 0.2223 0.8040 0.8180 0.1530 0.2818 Columns 19 through 36 0.4497 0.9992 0.1113 0.3388 0.9748 0.5187 0.4501 0.8950 0.0941 0.8712 0.2550 0.8094 0.4739 0.8115 0.5606 0.8147 0.5271 0.4556 Columns 37 through 50 0.7131 0.6058 0.3632 0.1578 0.8470 0.6654 0.7677 0.9585 0.8402 0.5512 0.7098 0.6117 0.7062 0.2358

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'