Cody

# Problem 6. Select every other element of a vector

Solution 1854477

Submitted on 20 Jun 2019 by Adam T. Serros
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.8064 y = 0.8064 0.2593 y = 0.8064 0.2593 0.5197 y = 0.8064 0.2593 0.5197 0.8555 y = 0.8064 0.2593 0.5197 0.8555 0.2186

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

y = 0.2586 y = 0.2586 0.0303 y = 0.2586 0.0303 0.1426 y = 0.2586 0.0303 0.1426 0.6911 y = 0.2586 0.0303 0.1426 0.6911 0.8283 y = 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 y = 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 y = 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 y = 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 y = 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 y = 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 y = 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 y = 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 y = 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 y = 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 y = 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 y = 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 y = 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Column 19 0.9215 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 20 0.9215 0.3096 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 21 0.9215 0.3096 0.5892 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 22 0.9215 0.3096 0.5892 0.1917 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 23 0.9215 0.3096 0.5892 0.1917 0.0681 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 24 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 25 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 26 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 27 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 0.2650 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 28 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 0.2650 0.7383 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 29 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 0.2650 0.7383 0.6808 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 30 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 0.2650 0.7383 0.6808 0.3363 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 31 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 0.2650 0.7383 0.6808 0.3363 0.7327 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 32 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 0.2650 0.7383 0.6808 0.3363 0.7327 0.4553 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 33 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 0.2650 0.7383 0.6808 0.3363 0.7327 0.4553 0.8677 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 34 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 0.2650 0.7383 0.6808 0.3363 0.7327 0.4553 0.8677 0.7958 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 35 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 0.2650 0.7383 0.6808 0.3363 0.7327 0.4553 0.8677 0.7958 0.6867 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 36 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 0.2650 0.7383 0.6808 0.3363 0.7327 0.4553 0.8677 0.7958 0.6867 0.2997 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 36 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 0.2650 0.7383 0.6808 0.3363 0.7327 0.4553 0.8677 0.7958 0.6867 0.2997 Column 37 0.8534 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 36 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 0.2650 0.7383 0.6808 0.3363 0.7327 0.4553 0.8677 0.7958 0.6867 0.2997 Columns 37 through 38 0.8534 0.2373 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 36 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 0.2650 0.7383 0.6808 0.3363 0.7327 0.4553 0.8677 0.7958 0.6867 0.2997 Columns 37 through 39 0.8534 0.2373 0.6012 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 36 0.9215 0.3096 0.5892 0.1917 0.0681 0.1812 0.1013 0.7722 0.2650 0.7383 0.6808 0.3363 0.7327 0.4553 0.8677 0.7958 0.6867 0.2997 Columns 37 through 40 0.8534 0.2373 0.6012 0.5429 y = Columns 1 through 18 0.2586 0.0303 0.1426 0.6911 0.8283 0.1353 0.7049 0.9078 0.5404 0.9733 0.6626 0.0527 0.2160 0.9031 0.0943 0.3599 0.3928 0.2294 Columns 19 through 36 0.9215 0.3096 0.5892 0.19...

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'