Cody

# Problem 6. Select every other element of a vector

Solution 1985216

Submitted on 22 Oct 2019 by Adobe Fl
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.0815 y = 0.0815 0.6588 y = 0.0815 0.6588 0.8049 y = 0.0815 0.6588 0.8049 0.1523 y = 0.0815 0.6588 0.8049 0.1523 0.9659

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

y = 0.4902 y = 0.4902 0.9594 y = 0.4902 0.9594 0.0876 y = 0.4902 0.9594 0.0876 0.1940 y = 0.4902 0.9594 0.0876 0.1940 0.4719 y = 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 y = 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 y = 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 y = 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 y = 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 y = 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 y = 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 y = 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 y = 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 y = 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 y = 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 y = 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 y = 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Column 19 0.7674 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 20 0.7674 0.1275 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 21 0.7674 0.1275 0.2909 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 22 0.7674 0.1275 0.2909 0.0286 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 23 0.7674 0.1275 0.2909 0.0286 0.2949 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 24 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 25 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 26 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 27 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 0.1813 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 28 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 0.1813 0.9160 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 29 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 0.1813 0.9160 0.1848 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 30 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 0.1813 0.9160 0.1848 0.4109 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 31 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 0.1813 0.9160 0.1848 0.4109 0.3884 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 32 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 0.1813 0.9160 0.1848 0.4109 0.3884 0.2859 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 33 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 0.1813 0.9160 0.1848 0.4109 0.3884 0.2859 0.4082 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 34 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 0.1813 0.9160 0.1848 0.4109 0.3884 0.2859 0.4082 0.4034 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 35 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 0.1813 0.9160 0.1848 0.4109 0.3884 0.2859 0.4082 0.4034 0.3954 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 36 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 0.1813 0.9160 0.1848 0.4109 0.3884 0.2859 0.4082 0.4034 0.3954 0.7187 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 36 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 0.1813 0.9160 0.1848 0.4109 0.3884 0.2859 0.4082 0.4034 0.3954 0.7187 Column 37 0.6815 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 36 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 0.1813 0.9160 0.1848 0.4109 0.3884 0.2859 0.4082 0.4034 0.3954 0.7187 Columns 37 through 38 0.6815 0.3711 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 36 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 0.1813 0.9160 0.1848 0.4109 0.3884 0.2859 0.4082 0.4034 0.3954 0.7187 Columns 37 through 39 0.6815 0.3711 0.1866 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 36 0.7674 0.1275 0.2909 0.0286 0.2949 0.7407 0.3044 0.5103 0.1813 0.9160 0.1848 0.4109 0.3884 0.2859 0.4082 0.4034 0.3954 0.7187 Columns 37 through 40 0.6815 0.3711 0.1866 0.5517 y = Columns 1 through 18 0.4902 0.9594 0.0876 0.1940 0.4719 0.9348 0.6724 0.5173 0.4749 0.4050 0.4394 0.8924 0.0873 0.1753 0.4009 0.3875 0.4560 0.1887 Columns 19 through 36 0.7674 0.1275 0.2909 0.02...

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'