Cody

# Problem 6. Select every other element of a vector

Solution 1894568

Submitted on 8 Aug 2019 by Yuumi Ozaki
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))

r = 10 p = 1 y = 0.4566 p = 2 y = 0.4566 0.7698 p = 3 y = 0.4566 0.7698 0.2558 p = 4 y = 0.4566 0.7698 0.2558 0.4991 p = 5 y = 0.4566 0.7698 0.2558 0.4991 0.2235 p = 6

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

r = 100 p = 1 y = 0.2431 p = 2 y = 0.2431 0.1797 p = 3 y = 0.2431 0.1797 0.9918 p = 4 y = 0.2431 0.1797 0.9918 0.7632 p = 5 y = 0.2431 0.1797 0.9918 0.7632 0.8483 p = 6 y = 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 p = 7 y = 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 p = 8 y = 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 p = 9 y = 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 p = 10 y = 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 p = 11 y = 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 p = 12 y = 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 p = 13 y = 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 p = 14 y = 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 p = 15 y = 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 p = 16 y = 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 p = 17 y = 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 p = 18 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Column 18 0.9404 p = 19 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 19 0.9404 0.4679 p = 20 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 20 0.9404 0.4679 0.3417 p = 21 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 21 0.9404 0.4679 0.3417 0.4669 p = 22 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 22 0.9404 0.4679 0.3417 0.4669 0.2995 p = 23 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 23 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 p = 24 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 24 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 p = 25 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 25 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 p = 26 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 26 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 0.3876 p = 27 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 27 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 0.3876 0.6754 p = 28 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 28 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 0.3876 0.6754 0.7535 p = 29 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 29 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 0.3876 0.6754 0.7535 0.9592 p = 30 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 30 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 0.3876 0.6754 0.7535 0.9592 0.0942 p = 31 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 31 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 0.3876 0.6754 0.7535 0.9592 0.0942 0.6280 p = 32 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 32 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 0.3876 0.6754 0.7535 0.9592 0.0942 0.6280 0.2946 p = 33 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 33 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 0.3876 0.6754 0.7535 0.9592 0.0942 0.6280 0.2946 0.8027 p = 34 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 34 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 0.3876 0.6754 0.7535 0.9592 0.0942 0.6280 0.2946 0.8027 0.4774 p = 35 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 34 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 0.3876 0.6754 0.7535 0.9592 0.0942 0.6280 0.2946 0.8027 0.4774 Column 35 0.1014 p = 36 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 34 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 0.3876 0.6754 0.7535 0.9592 0.0942 0.6280 0.2946 0.8027 0.4774 Columns 35 through 36 0.1014 0.8623 p = 37 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 34 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 0.3876 0.6754 0.7535 0.9592 0.0942 0.6280 0.2946 0.8027 0.4774 Columns 35 through 37 0.1014 0.8623 0.7825 p = 38 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 34 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 0.3876 0.6754 0.7535 0.9592 0.0942 0.6280 0.2946 0.8027 0.4774 Columns 35 through 38 0.1014 0.8623 0.7825 0.0535 p = 39 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 0.7635 0.5303 0.3876 0.1120 0.4892 0.4454 0.8438 0.0057 0.3650 0.7504 0.5386 0.6894 Columns 18 through 34 0.9404 0.4679 0.3417 0.4669 0.2995 0.4908 0.1022 0.3618 0.3876 0.6754 0.7535 0.9592 0.0942 0.6280 0.2946 0.8027 0.4774 Columns 35 through 39 0.1014 0.8623 0.7825 0.0535 0.0417 p = 40 y = Columns 1 through 17 0.2431 0.1797 0.9918 0.7632 0.8483 ...

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

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