Cody

# Problem 6. Select every other element of a vector

Solution 1697635

Submitted on 20 Dec 2018 by Konark Kumbhalkar
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.9633 y = 0.9633 0.9041 y = 0.9633 0.9041 0.0181 y = 0.9633 0.9041 0.0181 0.6572 y = 0.9633 0.9041 0.0181 0.6572 0.3969

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

y = 0.8046 y = 0.8046 0.6613 y = 0.8046 0.6613 0.9932 y = 0.8046 0.6613 0.9932 0.9976 y = 0.8046 0.6613 0.9932 0.9976 0.6289 y = 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 y = 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 y = 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 y = 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 y = 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 y = 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 y = 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 y = 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 y = 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 y = 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 y = 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 y = 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 y = 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Column 19 0.4197 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 20 0.4197 0.7663 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 21 0.4197 0.7663 0.4609 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 22 0.4197 0.7663 0.4609 0.2279 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 23 0.4197 0.7663 0.4609 0.2279 0.3677 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 24 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 25 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 26 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 27 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 0.2264 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 28 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 0.2264 0.5409 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 29 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 0.2264 0.5409 0.7156 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 30 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 0.2264 0.5409 0.7156 0.9140 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 31 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 0.2264 0.5409 0.7156 0.9140 0.8187 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 32 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 0.2264 0.5409 0.7156 0.9140 0.8187 0.3082 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 33 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 0.2264 0.5409 0.7156 0.9140 0.8187 0.3082 0.4844 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 34 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 0.2264 0.5409 0.7156 0.9140 0.8187 0.3082 0.4844 0.3111 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 35 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 0.2264 0.5409 0.7156 0.9140 0.8187 0.3082 0.4844 0.3111 0.6828 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 36 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 0.2264 0.5409 0.7156 0.9140 0.8187 0.3082 0.4844 0.3111 0.6828 0.3821 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 36 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 0.2264 0.5409 0.7156 0.9140 0.8187 0.3082 0.4844 0.3111 0.6828 0.3821 Column 37 0.0077 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 36 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 0.2264 0.5409 0.7156 0.9140 0.8187 0.3082 0.4844 0.3111 0.6828 0.3821 Columns 37 through 38 0.0077 0.4252 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 36 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 0.2264 0.5409 0.7156 0.9140 0.8187 0.3082 0.4844 0.3111 0.6828 0.3821 Columns 37 through 39 0.0077 0.4252 0.1918 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 36 0.4197 0.7663 0.4609 0.2279 0.3677 0.8362 0.2006 0.7728 0.2264 0.5409 0.7156 0.9140 0.8187 0.3082 0.4844 0.3111 0.6828 0.3821 Columns 37 through 40 0.0077 0.4252 0.1918 0.1915 y = Columns 1 through 18 0.8046 0.6613 0.9932 0.9976 0.6289 0.8016 0.0460 0.0358 0.3307 0.7926 0.3385 0.6042 0.5034 0.7639 0.2285 0.1986 0.7251 0.6481 Columns 19 through 36 0.4197 0.7663 0.4609 0.22...

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'