Cody

# Problem 6. Select every other element of a vector

Solution 1840851

Submitted on 6 Jun 2019 by Navdha Agarwal
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.3472 y = 0.3472 0.0093 y = 0.3472 0.0093 0.3871 y = 0.3472 0.0093 0.3871 0.0133 y = 0.3472 0.0093 0.3871 0.0133 0.2415

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

y = 0.8901 y = 0.8901 0.1124 y = 0.8901 0.1124 0.4370 y = 0.8901 0.1124 0.4370 0.1209 y = 0.8901 0.1124 0.4370 0.1209 0.2698 y = 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 y = 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 y = 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 y = 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 y = 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 y = 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 y = 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 y = 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 y = 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 y = 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 y = 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 y = 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 y = 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Column 19 0.3406 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 20 0.3406 0.7835 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 21 0.3406 0.7835 0.0357 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 22 0.3406 0.7835 0.0357 0.3309 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 23 0.3406 0.7835 0.0357 0.3309 0.5635 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 24 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 25 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 26 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 27 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 0.0034 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 28 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 0.0034 0.4284 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 29 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 0.0034 0.4284 0.3240 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 30 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 0.0034 0.4284 0.3240 0.4994 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 31 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 0.0034 0.4284 0.3240 0.4994 0.1140 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 32 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 0.0034 0.4284 0.3240 0.4994 0.1140 0.6760 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 33 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 0.0034 0.4284 0.3240 0.4994 0.1140 0.6760 0.9662 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 34 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 0.0034 0.4284 0.3240 0.4994 0.1140 0.6760 0.9662 0.9874 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 35 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 0.0034 0.4284 0.3240 0.4994 0.1140 0.6760 0.9662 0.9874 0.1161 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 36 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 0.0034 0.4284 0.3240 0.4994 0.1140 0.6760 0.9662 0.9874 0.1161 0.1499 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 36 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 0.0034 0.4284 0.3240 0.4994 0.1140 0.6760 0.9662 0.9874 0.1161 0.1499 Column 37 0.9661 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 36 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 0.0034 0.4284 0.3240 0.4994 0.1140 0.6760 0.9662 0.9874 0.1161 0.1499 Columns 37 through 38 0.9661 0.7244 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 36 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 0.0034 0.4284 0.3240 0.4994 0.1140 0.6760 0.9662 0.9874 0.1161 0.1499 Columns 37 through 39 0.9661 0.7244 0.8700 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 36 0.3406 0.7835 0.0357 0.3309 0.5635 0.1597 0.1398 0.7638 0.0034 0.4284 0.3240 0.4994 0.1140 0.6760 0.9662 0.9874 0.1161 0.1499 Columns 37 through 40 0.9661 0.7244 0.8700 0.3522 y = Columns 1 through 18 0.8901 0.1124 0.4370 0.1209 0.2698 0.4853 0.3318 0.7752 0.1162 0.5760 0.2251 0.7889 0.0592 0.8092 0.9417 0.5263 0.6146 0.6540 Columns 19 through 36 0.3406 0.7835 0.0357 0.33...

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 = 'Ao' y = 'Aog' y = 'Aogi' y = 'Aogie' y = 'Aogieg' y = 'Aogiegi' y = 'Aogiegia' y = 'Aogiegiaa' y = 'Aogiegiaaa' y = 'Aogiegiaaay' y = 'Aogiegiaaaya' y = 'Aogiegiaaayaf' y = 'Aogiegiaaayafr' y = 'Aogiegiaaayafrw' y = 'Aogiegiaaayafrwy'