Cody

# Problem 6. Select every other element of a vector

Solution 2027888

Submitted on 19 Nov 2019 by Devanarayanan Meena Narayana Menon
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.6793 j = 2 y = 0.6793 0.8841 j = 3 y = 0.6793 0.8841 0.9685 j = 4 y = 0.6793 0.8841 0.9685 0.9214 j = 5 y = 0.6793 0.8841 0.9685 0.9214 0.1936 j = 6

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

y = 0.8789 j = 2 y = 0.8789 0.4478 j = 3 y = 0.8789 0.4478 0.2278 j = 4 y = 0.8789 0.4478 0.2278 0.6122 j = 5 y = 0.8789 0.4478 0.2278 0.6122 0.0385 j = 6 y = 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 j = 7 y = 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 j = 8 y = 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 j = 9 y = 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 j = 10 y = 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 j = 11 y = 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 j = 12 y = 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 j = 13 y = 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 j = 14 y = 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 j = 15 y = 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 j = 16 y = 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 j = 17 y = 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 j = 18 y = 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 j = 19 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Column 19 0.3661 j = 20 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 20 0.3661 0.3608 j = 21 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 21 0.3661 0.3608 0.3981 j = 22 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 22 0.3661 0.3608 0.3981 0.7711 j = 23 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 23 0.3661 0.3608 0.3981 0.7711 0.7930 j = 24 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 24 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 j = 25 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 25 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 j = 26 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 26 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 0.1224 j = 27 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 27 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 0.1224 0.0105 j = 28 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 28 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 0.1224 0.0105 0.2479 j = 29 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 29 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 0.1224 0.0105 0.2479 0.4456 j = 30 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 30 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 0.1224 0.0105 0.2479 0.4456 0.2086 j = 31 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 31 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 0.1224 0.0105 0.2479 0.4456 0.2086 0.2937 j = 32 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 32 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 0.1224 0.0105 0.2479 0.4456 0.2086 0.2937 0.7199 j = 33 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 33 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 0.1224 0.0105 0.2479 0.4456 0.2086 0.2937 0.7199 0.4167 j = 34 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 34 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 0.1224 0.0105 0.2479 0.4456 0.2086 0.2937 0.7199 0.4167 0.2454 j = 35 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 35 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 0.1224 0.0105 0.2479 0.4456 0.2086 0.2937 0.7199 0.4167 0.2454 0.6231 j = 36 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 36 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 0.1224 0.0105 0.2479 0.4456 0.2086 0.2937 0.7199 0.4167 0.2454 0.6231 0.3250 j = 37 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 36 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 0.1224 0.0105 0.2479 0.4456 0.2086 0.2937 0.7199 0.4167 0.2454 0.6231 0.3250 Column 37 0.1769 j = 38 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 36 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 0.1224 0.0105 0.2479 0.4456 0.2086 0.2937 0.7199 0.4167 0.2454 0.6231 0.3250 Columns 37 through 38 0.1769 0.5929 j = 39 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 Columns 19 through 36 0.3661 0.3608 0.3981 0.7711 0.7930 0.0617 0.9875 0.1224 0.0105 0.2479 0.4456 0.2086 0.2937 0.7199 0.4167 0.2454 0.6231 0.3250 Columns 37 through 39 0.1769 0.5929 0.1418 j = 40 y = Columns 1 through 18 0.8789 0.4478 0.2278 0.6122 0.0385 0.5568 0.0770 0.3779 0.5807 0.9762 0.1988 0.4523 0.3340 0.3727 0.6335 0.7468 0.1908 0.6793 C...

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' j = 2 y = 'Ao' j = 3 y = 'Aog' j = 4 y = 'Aogi' j = 5 y = 'Aogie' j = 6 y = 'Aogieg' j = 7 y = 'Aogiegi' j = 8 y = 'Aogiegia' j = 9 y = 'Aogiegiaa' j = 10 y = 'Aogiegiaaa' j = 11 y = 'Aogiegiaaay' j = 12 y = 'Aogiegiaaaya' j = 13 y = 'Aogiegiaaayaf' j = 14 y = 'Aogiegiaaayafr' j = 15 y = 'Aogiegiaaayafrw' j = 16 y = 'Aogiegiaaayafrwy' j = 17