Cody

Problem 6. Select every other element of a vector

Solution 2032235

Submitted on 22 Nov 2019 by Jaideep Kanthak
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.7941 n = 2 y = 0.7941 0.6217 n = 3 y = 0.7941 0.6217 0.7759 n = 4 y = 0.7941 0.6217 0.7759 0.1545 n = 5 y = 0.7941 0.6217 0.7759 0.1545 0.0584 n = 6 0.7941 0.1556 0.6217 0.5006 0.7759 0.1101 0.1545 0.4013 0.0584 0.3243

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

y = 0.2138 n = 2 y = 0.2138 0.9586 n = 3 y = 0.2138 0.9586 0.0293 n = 4 y = 0.2138 0.9586 0.0293 0.6519 n = 5 y = 0.2138 0.9586 0.0293 0.6519 0.1663 n = 6 y = 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 n = 7 y = 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 n = 8 y = 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 n = 9 y = 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 n = 10 y = 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 n = 11 y = 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 n = 12 y = 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 n = 13 y = 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 n = 14 y = 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 n = 15 y = 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 n = 16 y = 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 n = 17 y = 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 n = 18 y = 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 n = 19 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Column 19 0.7236 n = 20 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 20 0.7236 0.0117 n = 21 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 21 0.7236 0.0117 0.2925 n = 22 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 22 0.7236 0.0117 0.2925 0.8699 n = 23 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 23 0.7236 0.0117 0.2925 0.8699 0.6226 n = 24 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 24 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 n = 25 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 25 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 n = 26 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 26 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 0.4431 n = 27 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 27 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 0.4431 0.3256 n = 28 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 28 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 0.4431 0.3256 0.9081 n = 29 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 29 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 0.4431 0.3256 0.9081 0.6529 n = 30 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 30 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 0.4431 0.3256 0.9081 0.6529 0.5483 n = 31 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 31 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 0.4431 0.3256 0.9081 0.6529 0.5483 0.6112 n = 32 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 32 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 0.4431 0.3256 0.9081 0.6529 0.5483 0.6112 0.5128 n = 33 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 33 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 0.4431 0.3256 0.9081 0.6529 0.5483 0.6112 0.5128 0.9135 n = 34 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 34 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 0.4431 0.3256 0.9081 0.6529 0.5483 0.6112 0.5128 0.9135 0.0225 n = 35 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 35 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 0.4431 0.3256 0.9081 0.6529 0.5483 0.6112 0.5128 0.9135 0.0225 0.1686 n = 36 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 36 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 0.4431 0.3256 0.9081 0.6529 0.5483 0.6112 0.5128 0.9135 0.0225 0.1686 0.8136 n = 37 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 36 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 0.4431 0.3256 0.9081 0.6529 0.5483 0.6112 0.5128 0.9135 0.0225 0.1686 0.8136 Column 37 0.6913 n = 38 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 36 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 0.4431 0.3256 0.9081 0.6529 0.5483 0.6112 0.5128 0.9135 0.0225 0.1686 0.8136 Columns 37 through 38 0.6913 0.8523 n = 39 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 Columns 19 through 36 0.7236 0.0117 0.2925 0.8699 0.6226 0.6377 0.9399 0.4431 0.3256 0.9081 0.6529 0.5483 0.6112 0.5128 0.9135 0.0225 0.1686 0.8136 Columns 37 through 39 0.6913 0.8523 0.0233 n = 40 y = Columns 1 through 18 0.2138 0.9586 0.0293 0.6519 0.1663 0.0885 0.1863 0.0290 0.3117 0.9463 0.9299 0.2127 0.6013 0.3911 0.7362 0.7822 0.7951 0.6353 C...

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' n = 2 y = 'Ao' n = 3 y = 'Aog' n = 4 y = 'Aogi' n = 5 y = 'Aogie' n = 6 y = 'Aogieg' n = 7 y = 'Aogiegi' n = 8 y = 'Aogiegia' n = 9 y = 'Aogiegiaa' n = 10 y = 'Aogiegiaaa' n = 11 y = 'Aogiegiaaay' n = 12 y = 'Aogiegiaaaya' n = 13 y = 'Aogiegiaaayaf' n = 14 y = 'Aogiegiaaayafr' n = 15 y = 'Aogiegiaaayafrw' n = 16 y = 'Aogiegiaaayafrwy' n = 17 Alongtimeagoinagalaxyfarfaraway

Suggested Problems

More from this Author95