Cody

# Problem 6. Select every other element of a vector

Solution 1901265

Submitted on 15 Aug 2019 by bingi vishal
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))

a = 0.0520 a = 0.0520 0.8101 a = 0.0520 0.8101 0.7875 a = 0.0520 0.8101 0.7875 0.6686 a = 0.0520 0.8101 0.7875 0.6686 0.6564

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

a = 0.0788 a = 0.0788 0.9156 a = 0.0788 0.9156 0.3267 a = 0.0788 0.9156 0.3267 0.5861 a = 0.0788 0.9156 0.3267 0.5861 0.3778 a = 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 a = 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 a = 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 a = 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 a = 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 a = 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 a = 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 a = 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 a = 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 a = 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 a = 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 a = 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 a = 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Column 19 0.8487 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 20 0.8487 0.8105 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 21 0.8487 0.8105 0.9770 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 22 0.8487 0.8105 0.9770 0.0537 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 23 0.8487 0.8105 0.9770 0.0537 0.6561 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 24 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 25 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 26 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 27 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 0.3358 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 28 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 0.3358 0.2744 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 29 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 0.3358 0.2744 0.2928 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 30 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 0.3358 0.2744 0.2928 0.6920 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 31 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 0.3358 0.2744 0.2928 0.6920 0.7102 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 32 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 0.3358 0.2744 0.2928 0.6920 0.7102 0.8066 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 33 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 0.3358 0.2744 0.2928 0.6920 0.7102 0.8066 0.1829 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 34 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 0.3358 0.2744 0.2928 0.6920 0.7102 0.8066 0.1829 0.5593 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 35 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 0.3358 0.2744 0.2928 0.6920 0.7102 0.8066 0.1829 0.5593 0.3454 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 36 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 0.3358 0.2744 0.2928 0.6920 0.7102 0.8066 0.1829 0.5593 0.3454 0.0948 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 36 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 0.3358 0.2744 0.2928 0.6920 0.7102 0.8066 0.1829 0.5593 0.3454 0.0948 Column 37 0.2094 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 36 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 0.3358 0.2744 0.2928 0.6920 0.7102 0.8066 0.1829 0.5593 0.3454 0.0948 Columns 37 through 38 0.2094 0.8815 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 36 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 0.3358 0.2744 0.2928 0.6920 0.7102 0.8066 0.1829 0.5593 0.3454 0.0948 Columns 37 through 39 0.2094 0.8815 0.3312 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 36 0.8487 0.8105 0.9770 0.0537 0.6561 0.1311 0.8590 0.8319 0.3358 0.2744 0.2928 0.6920 0.7102 0.8066 0.1829 0.5593 0.3454 0.0948 Columns 37 through 40 0.2094 0.8815 0.3312 0.9092 a = Columns 1 through 18 0.0788 0.9156 0.3267 0.5861 0.3778 0.8097 0.0271 0.1232 0.8983 0.9592 0.7082 0.2490 0.8326 0.9841 0.4349 0.0412 0.2136 0.8334 Columns 19 through 36 0.8487 0.8105 0.9770 0.05...

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

a = 'A' a = 'Ao' a = 'Aog' a = 'Aogi' a = 'Aogie' a = 'Aogieg' a = 'Aogiegi' a = 'Aogiegia' a = 'Aogiegiaa' a = 'Aogiegiaaa' a = 'Aogiegiaaay' a = 'Aogiegiaaaya' a = 'Aogiegiaaayaf' a = 'Aogiegiaaayafr' a = 'Aogiegiaaayafrw' a = 'Aogiegiaaayafrwy'