Cody

# Problem 6. Select every other element of a vector

Solution 2080339

Submitted on 4 Jan 2020 by Laura Gialloreto
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))

n = 10 c = 1 y = 0.4176 c = 2 y = 0.4176 0.2445 c = 3 y = 0.4176 0.2445 0.0417 c = 4 y = 0.4176 0.2445 0.0417 0.2865 c = 5 y = 0.4176 0.2445 0.0417 0.2865 0.2209 c = 6

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

n = 100 c = 1 y = 0.9794 c = 2 y = 0.9794 0.1473 c = 3 y = 0.9794 0.1473 0.4649 c = 4 y = 0.9794 0.1473 0.4649 0.2929 c = 5 y = 0.9794 0.1473 0.4649 0.2929 0.5103 c = 6 y = 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 c = 7 y = 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 c = 8 y = 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 c = 9 y = 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 c = 10 y = 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 c = 11 y = 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 c = 12 y = 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 c = 13 y = 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 c = 14 y = 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 c = 15 y = 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 c = 16 y = 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 c = 17 y = 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 c = 18 y = 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 c = 19 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Column 19 0.6703 c = 20 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 20 0.6703 0.5660 c = 21 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 21 0.6703 0.5660 0.5182 c = 22 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 22 0.6703 0.5660 0.5182 0.1576 c = 23 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 23 0.6703 0.5660 0.5182 0.1576 0.0515 c = 24 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 24 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 c = 25 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 25 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 c = 26 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 26 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 0.2068 c = 27 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 27 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 0.2068 0.7185 c = 28 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 28 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 0.2068 0.7185 0.6074 c = 29 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 29 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 0.2068 0.7185 0.6074 0.0668 c = 30 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 30 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 0.2068 0.7185 0.6074 0.0668 0.8911 c = 31 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 31 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 0.2068 0.7185 0.6074 0.0668 0.8911 0.0008 c = 32 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 32 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 0.2068 0.7185 0.6074 0.0668 0.8911 0.0008 0.8701 c = 33 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 33 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 0.2068 0.7185 0.6074 0.0668 0.8911 0.0008 0.8701 0.6361 c = 34 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 34 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 0.2068 0.7185 0.6074 0.0668 0.8911 0.0008 0.8701 0.6361 0.4078 c = 35 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 35 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 0.2068 0.7185 0.6074 0.0668 0.8911 0.0008 0.8701 0.6361 0.4078 0.9203 c = 36 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 36 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 0.2068 0.7185 0.6074 0.0668 0.8911 0.0008 0.8701 0.6361 0.4078 0.9203 0.9203 c = 37 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 36 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 0.2068 0.7185 0.6074 0.0668 0.8911 0.0008 0.8701 0.6361 0.4078 0.9203 0.9203 Column 37 0.2277 c = 38 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 36 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 0.2068 0.7185 0.6074 0.0668 0.8911 0.0008 0.8701 0.6361 0.4078 0.9203 0.9203 Columns 37 through 38 0.2277 0.7899 c = 39 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0127 0.6297 0.3040 Columns 19 through 36 0.6703 0.5660 0.5182 0.1576 0.0515 0.1290 0.1160 0.2068 0.7185 0.6074 0.0668 0.8911 0.0008 0.8701 0.6361 0.4078 0.9203 0.9203 Columns 37 through 39 0.2277 0.7899 0.1233 c = 40 y = Columns 1 through 18 0.9794 0.1473 0.4649 0.2929 0.5103 0.0089 0.1436 0.5340 0.6917 0.9868 0.5011 0.6595 0.7583 0.7628 0.1240 0.0...

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))

n = 31 c = 1 y = 'A' c = 2 y = 'Ao' c = 3 y = 'Aog' c = 4 y = 'Aogi' c = 5 y = 'Aogie' c = 6 y = 'Aogieg' c = 7 y = 'Aogiegi' c = 8 y = 'Aogiegia' c = 9 y = 'Aogiegiaa' c = 10 y = 'Aogiegiaaa' c = 11 y = 'Aogiegiaaay' c = 12 y = 'Aogiegiaaaya' c = 13 y = 'Aogiegiaaayaf' c = 14 y = 'Aogiegiaaayafr' c = 15 y = 'Aogiegiaaayafrw' c = 16 y = 'Aogiegiaaayafrwy' c = 17