Cody

Problem 6. Select every other element of a vector

Solution 2019704

Submitted on 14 Nov 2019 by Jack Burness
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.6721 0.7365 0.1599 0.1192 0.3660

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.5805 0.1288 0.1038 0.0657 0.0127 0.9919 0.1632 0.3159 0.1080 0.0184 0.7759 0.5560 0.8478 0.5627 0.0888 0.3922 0.6173 0.3333 Columns 19 through 36 0.5872 0.9246 0.0036 0.8073 0.9650 0.3475 0.0033 0.3269 0.6423 0.7043 0.3693 0.9132 0.6899 0.9723 0.1686 0.0757 0.7599 0.8302 Columns 37 through 50 0.7074 0.8749 0.5152 0.7730 0.6381 0.2179 0.3900 0.3393 0.2377 0.2368 0.2662 0.8610 0.9588 0.9134

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'