Cody

Problem 6. Select every other element of a vector

Solution 1760661

Submitted on 25 Mar 2019 by Utkarsh Dixit
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.3972 0.9576 0.1231 0.6576 0.7774

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.3476 0.8351 0.0815 0.7969 0.2507 0.8328 0.6390 0.0882 0.6782 0.0158 0.7339 0.8704 0.8729 0.1494 0.2692 0.3277 0.3465 0.4867 Columns 19 through 36 0.5906 0.6720 0.6278 0.2528 0.0795 0.2015 0.1765 0.6134 0.6356 0.3352 0.7018 0.1511 0.6673 0.8205 0.1281 0.9306 0.1647 0.8891 Columns 37 through 50 0.0103 0.2609 0.5595 0.5948 0.1365 0.9040 0.2100 0.6685 0.5211 0.0617 0.0999 0.8550 0.2849 0.6481

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'