Cody

# Problem 6. Select every other element of a vector

Solution 1279243

Submitted on 30 Sep 2017 by Matthew McDonnell
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.6893 y = 0.6893 0 0.4599 y = 0.6893 0 0.4599 0 0.5739 y = 0.6893 0 0.4599 0 0.5739 0 0.2133 y = 0.6893 0 0.4599 0 0.5739 0 0.2133 0 0.4968 y = 0.6893 0.4599 0.5739 0.2133 0.4968

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

y = 0.3983 y = 0.3983 0 0.9920 y = 0.3983 0 0.9920 0 0.3830 y = 0.3983 0 0.9920 0 0.3830 0 0.4425 y = 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 y = 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 y = 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 y = 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 y = 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Column 19 0.3955 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 21 0.3955 0 0.5482 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 23 0.3955 0 0.5482 0 0.0649 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 25 0.3955 0 0.5482 0 0.0649 0 0.6483 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 27 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 29 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 31 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 0 0.4412 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 33 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 0 0.4412 0 0.0483 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 35 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 0 0.4412 0 0.0483 0 0.1442 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 36 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 0 0.4412 0 0.0483 0 0.1442 0 Column 37 0.8939 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 36 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 0 0.4412 0 0.0483 0 0.1442 0 Columns 37 through 39 0.8939 0 0.2493 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 36 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 0 0.4412 0 0.0483 0 0.1442 0 Columns 37 through 41 0.8939 0 0.2493 0 0.1783 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 36 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 0 0.4412 0 0.0483 0 0.1442 0 Columns 37 through 43 0.8939 0 0.2493 0 0.1783 0 0.6056 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 36 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 0 0.4412 0 0.0483 0 0.1442 0 Columns 37 through 45 0.8939 0 0.2493 0 0.1783 0 0.6056 0 0.7347 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 36 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 0 0.4412 0 0.0483 0 0.1442 0 Columns 37 through 47 0.8939 0 0.2493 0 0.1783 0 0.6056 0 0.7347 0 0.5460 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 36 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 0 0.4412 0 0.0483 0 0.1442 0 Columns 37 through 49 0.8939 0 0.2493 0 0.1783 0 0.6056 0 0.7347 0 0.5460 0 0.0738 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 36 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 0 0.4412 0 0.0483 0 0.1442 0 Columns 37 through 51 0.8939 0 0.2493 0 0.1783 0 0.6056 0 0.7347 0 0.5460 0 0.0738 0 0.0284 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 36 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 0 0.4412 0 0.0483 0 0.1442 0 Columns 37 through 53 0.8939 0 0.2493 0 0.1783 0 0.6056 0 0.7347 0 0.5460 0 0.0738 0 0.0284 0 0.3697 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 36 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 0 0.4412 0 0.0483 0 0.1442 0 Columns 37 through 54 0.8939 0 0.2493 0 0.1783 0 0.6056 0 0.7347 0 0.5460 0 0.0738 0 0.0284 0 0.3697 0 Column 55 0.8033 y = Columns 1 through 18 0.3983 0 0.9920 0 0.3830 0 0.4425 0 0.1083 0 0.1556 0 0.4651 0 0.7132 0 0.5428 0 Columns 19 through 36 0.3955 0 0.5482 0 0.0649 0 0.6483 0 0.3345 0 0.9688 0 0.4412 0 0.0483 0 0.1442 0 Columns 37 through 54 0.8939 0 0.2493 0 0.1783 0 0.6056 0 0.7347 0 0.5460 0 0.0738 0 0.0284 0 0.3697 0 Columns 55 through 57 0.8033 0 0.7330 y = Columns 1 throug...

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 = 'A' y = 'A o' y = 'A o g' y = 'A o g i' y = 'A o g i e' y = 'A o g i e g' y = 'A o g i e g i' y = 'A o g i e g i a' y = 'A o g i e g i a a' y = 'A o g i e g i a a a' y = 'A o g i e g i a a a y' y = 'A o g i e g i a a a y a' y = 'A o g i e g i a a a y a f' y = 'A o g i e g i a a a y a f r' y = 'A o g i e g i a a a y a f r w' y = 'A o g i e g i a a a y a f r w y' y = 'Aogiegiaaayafrwy'