Cody

# Problem 6. Select every other element of a vector

Solution 1771687

Submitted on 3 Apr 2019 by Riccardo D'Angelo
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))

d = 0 d = 1 y = 0.8860 d = 2 y = 0.8860 0.4596 d = 3 y = 0.8860 0.4596 0.9762 d = 4 y = 0.8860 0.4596 0.9762 0.9083 d = 5 y = 0.8860 0.4596 0.9762 0.9083 0.6803

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

d = 0 d = 1 y = 0.5014 d = 2 y = 0.5014 0.7752 d = 3 y = 0.5014 0.7752 0.8539 d = 4 y = 0.5014 0.7752 0.8539 0.7728 d = 5 y = 0.5014 0.7752 0.8539 0.7728 0.2685 d = 6 y = 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 d = 7 y = 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 d = 8 y = 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 d = 9 y = 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 d = 10 y = 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 d = 11 y = 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 d = 12 y = 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 d = 13 y = 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 d = 14 y = 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 d = 15 y = 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 d = 16 y = 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 d = 17 y = 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 d = 18 y = 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 d = 19 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Column 19 0.4970 d = 20 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 20 0.4970 0.0853 d = 21 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 21 0.4970 0.0853 0.1617 d = 22 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 22 0.4970 0.0853 0.1617 0.9495 d = 23 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 23 0.4970 0.0853 0.1617 0.9495 0.5323 d = 24 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 24 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 d = 25 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 25 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 d = 26 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 26 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 0.8049 d = 27 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 27 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 0.8049 0.1007 d = 28 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 28 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 0.8049 0.1007 0.5477 d = 29 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 29 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 0.8049 0.1007 0.5477 0.2417 d = 30 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 30 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 0.8049 0.1007 0.5477 0.2417 0.6058 d = 31 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 31 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 0.8049 0.1007 0.5477 0.2417 0.6058 0.8418 d = 32 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 32 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 0.8049 0.1007 0.5477 0.2417 0.6058 0.8418 0.2005 d = 33 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 33 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 0.8049 0.1007 0.5477 0.2417 0.6058 0.8418 0.2005 0.9260 d = 34 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 34 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 0.8049 0.1007 0.5477 0.2417 0.6058 0.8418 0.2005 0.9260 0.7371 d = 35 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 35 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 0.8049 0.1007 0.5477 0.2417 0.6058 0.8418 0.2005 0.9260 0.7371 0.9079 d = 36 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 36 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 0.8049 0.1007 0.5477 0.2417 0.6058 0.8418 0.2005 0.9260 0.7371 0.9079 0.5504 d = 37 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 36 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 0.8049 0.1007 0.5477 0.2417 0.6058 0.8418 0.2005 0.9260 0.7371 0.9079 0.5504 Column 37 0.2562 d = 38 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 36 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 0.8049 0.1007 0.5477 0.2417 0.6058 0.8418 0.2005 0.9260 0.7371 0.9079 0.5504 Columns 37 through 38 0.2562 0.3021 d = 39 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1591 0.1920 0.8804 Columns 19 through 36 0.4970 0.0853 0.1617 0.9495 0.5323 0.7262 0.9006 0.8049 0.1007 0.5477 0.2417 0.6058 0.8418 0.2005 0.9260 0.7371 0.9079 0.5504 Columns 37 through 39 0.2562 0.3021 0.8725 d = 40 y = Columns 1 through 18 0.5014 0.7752 0.8539 0.7728 0.2685 0.4060 0.1814 0.6297 0.7910 0.6956 0.1244 0.2533 0.3748 0.3347 0.9382 0.1...

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

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