Cody

# Problem 6. Select every other element of a vector

Solution 523616

Submitted on 7 Nov 2014 by Divakar Kittur
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.4221 0.3847 0.1661 0.5656 0.5073 ans = []

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

y = Columns 1 through 9 0.2644 0.3196 0.3866 0.0148 0.5267 0.2674 0.7955 0.2823 0.3365 Columns 10 through 18 0.5478 0.0667 0.4747 0.8314 0.6354 0.7930 0.1655 0.5445 0.5832 Columns 19 through 27 0.4169 0.5107 0.9193 0.1048 0.6898 0.0396 0.2490 0.5891 0.7386 Columns 28 through 36 0.8362 0.4545 0.2954 0.4793 0.9389 0.6104 0.0890 0.4137 0.6014 Columns 37 through 45 0.7052 0.6658 0.7290 0.0051 0.0900 0.2245 0.4846 0.0078 0.7061 Columns 46 through 50 0.8367 0.5201 0.6986 0.9356 0.3280 ans = []

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 ans = []