Cody

# Problem 6. Select every other element of a vector

Solution 1803706

Submitted on 2 May 2019 by Giannis Astrinakis
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))

n = 1 y = 0.2053 0.2922 0.9064 0.5551 0.4554 n = 2 y = 0.2053 0.2922 0.9064 0.5551 0.4554 n = 3 y = 0.2053 0.2922 0.9064 0.5551 0.4554 n = 4 y = 0.2053 0.2922 0.9064 0.5551 0.4554 n = 5 y = 0.2053 0.2922 0.9064 0.5551 0.4554

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

n = 1 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 2 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 3 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 4 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 5 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 6 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 7 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 8 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 9 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 10 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 11 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 12 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 13 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 14 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 15 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 16 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785 0.1818 0.0812 0.9952 Columns 37 through 50 0.8259 0.6310 0.2105 0.1003 0.5457 0.4349 0.1286 0.3188 0.0315 0.9775 0.2665 0.2832 0.8875 0.7246 n = 17 y = Columns 1 through 18 0.1501 0.4475 0.0528 0.8970 0.3568 0.8482 0.2711 0.3566 0.4899 0.1415 0.5494 0.5313 0.3390 0.2803 0.9831 0.5108 0.7373 0.4207 Columns 19 through 36 0.5815 0.3293 0.5167 0.9229 0.7677 0.0567 0.3017 0.9851 0.2273 0.0877 0.6221 0.5095 0.3589 0.2733 0.9785...

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

n = 1 y = 'Aogiegiaaayafrwy' n = 2 y = 'Aogiegiaaayafrwy' n = 3 y = 'Aogiegiaaayafrwy' n = 4 y = 'Aogiegiaaayafrwy' n = 5 y = 'Aogiegiaaayafrwy' n = 6 y = 'Aogiegiaaayafrwy' n = 7 y = 'Aogiegiaaayafrwy' n = 8 y = 'Aogiegiaaayafrwy' n = 9 y = 'Aogiegiaaayafrwy' n = 10 y = 'Aogiegiaaayafrwy' n = 11 y = 'Aogiegiaaayafrwy' n = 12 y = 'Aogiegiaaayafrwy' n = 13 y = 'Aogiegiaaayafrwy' n = 14 y = 'Aogiegiaaayafrwy' n = 15 y = 'Aogiegiaaayafrwy'