Cody

# Problem 6. Select every other element of a vector

Solution 1921159

Submitted on 4 Sep 2019 by Logan Jones
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.4027 0.0434 0.9598 0.8294 0.1141 0.1581 0.8788 0.6734 0.2278 y = 0.4027 0.0434 0.8294 0.1141 0.1581 0.8788 0.6734 0.2278 y = 0.4027 0.0434 0.8294 0.1581 0.8788 0.6734 0.2278 y = 0.4027 0.0434 0.8294 0.1581 0.6734 0.2278 y = 0.4027 0.0434 0.8294 0.1581 0.6734

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

y = Columns 1 through 18 0.2042 0.7205 0.3775 0.0018 0.8106 0.4751 0.3134 0.6168 0.7408 0.5327 0.4771 0.6033 0.6472 0.7607 0.1329 0.9185 0.4314 0.3955 Columns 19 through 36 0.7297 0.1473 0.0513 0.7869 0.8998 0.7758 0.9592 0.7834 0.5294 0.9762 0.1702 0.8171 0.1715 0.2388 0.9447 0.0674 0.7837 0.9916 Columns 37 through 54 0.5547 0.2226 0.4250 0.5342 0.6153 0.8122 0.3594 0.3481 0.8889 0.3411 0.4593 0.7658 0.8746 0.8806 0.1704 0.8166 0.4705 0.3027 Columns 55 through 72 0.0617 0.7472 0.1019 0.4654 0.3790 0.4884 0.5347 0.0304 0.0941 0.8511 0.0878 0.7885 0.4037 0.0545 0.9211 0.1057 0.3727 0.7152 Columns 73 through 90 0.7221 0.7824 0.5497 0.0624 0.6367 0.6830 0.5039 0.9982 0.4930 0.6182 0.0806 0.1637 0.1192 0.5591 0.3517 0.3764 0.7472 0.7044 Columns 91 through 99 0.1543 0.4208 0.6824 0.5749 0.9823 0.1251 0.3348 0.0646 0.6055 y = Columns 1 through 18 0.2042 0.7205 0.0018 0.8106 0.4751 0.3134 0.6168 0.7408 0.5327 0.4771 0.6033 0.6472 0.7607 0.1329 0.9185 0.4314 0.3955 0.7297 Columns 19 through 36 0.1473 0.0513 0.7869 0.8998 0.7758 0.9592 0.7834 0.5294 0.9762 0.1702 0.8171 0.1715 0.2388 0.9447 0.0674 0.7837 0.9916 0.5547 Columns 37 through 54 0.2226 0.4250 0.5342 0.6153 0.8122 0.3594 0.3481 0.8889 0.3411 0.4593 0.7658 0.8746 0.8806 0.1704 0.8166 0.4705 0.3027 0.0617 Columns 55 through 72 0.7472 0.1019 0.4654 0.3790 0.4884 0.5347 0.0304 0.0941 0.8511 0.0878 0.7885 0.4037 0.0545 0.9211 0.1057 0.3727 0.7152 0.7221 Columns 73 through 90 0.7824 0.5497 0.0624 0.6367 0.6830 0.5039 0.9982 0.4930 0.6182 0.0806 0.1637 0.1192 0.5591 0.3517 0.3764 0.7472 0.7044 0.1543 Columns 91 through 98 0.4208 0.6824 0.5749 0.9823 0.1251 0.3348 0.0646 0.6055 y = Columns 1 through 18 0.2042 0.7205 0.0018 0.4751 0.3134 0.6168 0.7408 0.5327 0.4771 0.6033 0.6472 0.7607 0.1329 0.9185 0.4314 0.3955 0.7297 0.1473 Columns 19 through 36 0.0513 0.7869 0.8998 0.7758 0.9592 0.7834 0.5294 0.9762 0.1702 0.8171 0.1715 0.2388 0.9447 0.0674 0.7837 0.9916 0.5547 0.2226 Columns 37 through 54 0.4250 0.5342 0.6153 0.8122 0.3594 0.3481 0.8889 0.3411 0.4593 0.7658 0.8746 0.8806 0.1704 0.8166 0.4705 0.3027 0.0617 0.7472 Columns 55 through 72 0.1019 0.4654 0.3790 0.4884 0.5347 0.0304 0.0941 0.8511 0.0878 0.7885 0.4037 0.0545 0.9211 0.1057 0.3727 0.7152 0.7221 0.7824 Columns 73 through 90 0.5497 0.0624 0.6367 0.6830 0.5039 0.9982 0.4930 0.6182 0.0806 0.1637 0.1192 0.5591 0.3517 0.3764 0.7472 0.7044 0.1543 0.4208 Columns 91 through 97 0.6824 0.5749 0.9823 0.1251 0.3348 0.0646 0.6055 y = Columns 1 through 18 0.2042 0.7205 0.0018 0.4751 0.6168 0.7408 0.5327 0.4771 0.6033 0.6472 0.7607 0.1329 0.9185 0.4314 0.3955 0.7297 0.1473 0.0513 Columns 19 through 36 0.7869 0.8998 0.7758 0.9592 0.7834 0.5294 0.9762 0.1702 0.8171 0.1715 0.2388 0.9447 0.0674 0.7837 0.9916 0.5547 0.2226 0.4250 Columns 37 through 54 0.5342 0.6153 0.8122 0.3594 0.3481 0.8889 0.3411 0.4593 0.7658 0.8746 0.8806 0.1704 0.8166 0.4705 0.3027 0.0617 0.7472 0.1019 Columns 55 through 72 0.4654 0.3790 0.4884 0.5347 0.0304 0.0941 0.8511 0.0878 0.7885 0.4037 0.0545 0.9211 0.1057 0.3727 0.7152 0.7221 0.7824 0.5497 Columns 73 through 90 0.0624 0.6367 0.6830 0.5039 0.9982 0.4930 0.6182 0.0806 0.1637 0.1192 0.5591 0.3517 0.3764 0.7472 0.7044 0.1543 0.4208 0.6824 Columns 91 through 96 0.5749 0.9823 0.1251 0.3348 0.0646 0.6055 y = Columns 1 through 18 0.2042 0.7205 0.0018 0.4751 0.6168 0.5327 0.4771 0.6033 0.6472 0.7607 0.1329 0.9185 0.4314 0.3955 0.7297 0.1473 0.0513 0.7869 Columns 19 through 36 0.8998 0.7758 0.9592 0.7834 0.5294 0.9762 0.1702 0.8171 0.1715 0.2388 0.9447 0.0674 0.7837 0.9916 0.5547 0.2226 0.4250 0.5342 Columns 37 through 54 0.6153 0.8122 0.3594 0.3481 0.8889 0.3411 0.4593 0.7658 0.8746 0.8806 0.1704 0.8166 0.4705 0.3027 0.0617 0.7472 0.1019 0.4654 Columns 55 through 72 0.3790 0.4884 0.5347 0.0304 0.0941 0.8511 0.0878 0.7885 0.4037 0.0545 0.9211 0.1057 0.3727 0.7152 0.7221 0.7824 0.5497 0.0624 Columns 73 through 90 0.6367 0.6830 0.5039 0.9982 0.4930 0.6182 0.0806 0.1637 0.1192 0.5591 0.3517 0.3764 0.7472 0.7044 0.1543 0.4208 0.6824 0.5749 Columns 91 through 95 0.9823 0.1251 0.3348 0.0646 0.6055 y = Columns 1 through 18 0.2042 0.7205 0.0018 0.4751 0.6168 0.5327 0.6033 0.6472 0.7607 0.1329 0.9185 0.4314 0.3955 0.7297 0.1473 0.0513 0.7869 0.8998 Columns 19 through 36 0.7758 0.9592 0.7834 0.5294 0.9762 0.1702 0.8171 0.1715 0.2388 0.9447 0.0674 0.7837 0.9916 0.5547 0.2226 0.4250 0.5342 0.6153 Columns 37 through 54 0.8122 0.3594 0.3481 0.8889 0.3411 0.4593 0.7658 0.8746 0.8806 0.1704 0.8166 0.4705 0.3027 0.0617 0.7472 0.1019 0.4654 0.3790 Columns 55 through 72 0.4884 0.5347 0.0304 0.0941 0.8511 0.0878 0.7885 0.4037 0.0545 0.9211 0.1057 0.3727 0.7152 0.7221 0.7824 0.5497 0.0624 0.6367 Columns 73 through 90 0.6830 0.5039 0.9982 0.4930 0.6182 0.0806 0.1637 0.1192 0.5591 0.3517 0.3764 0.7472 0.7044 0.1543 0.4208 0.6824 0.5749 0.9823 Columns 91 through 94 0.1251 0.3348 0.0646 0.6055 y = Columns 1 through 18 0.2042 0.7205 0.0018 0.4751 0.6168 0.5327 0.6033 0.7607 0.1329 0.9185 0.4314 0.3955 0.7297 0.1473 0.0513 0.7869 0.8998 0.7758 Columns 19 through 36 0.9592 0.7834 0.5294 0.9762 0.1702 0.8171 0.1715 0.2388 0.9447 0.0674 0.7837 0.9916 0.5547 0.2226 0.4250 0.5342 0.6153 0.8122 Columns 37 through 54 0.3594 0.3481 0.8889 0.3411 0.4593 0.7658 0.8746 0.8806 0.1704 0.8166 0.4705 0.3027 0.0617 0.7472 0.1019 0.4654 0.3790 0.4884 Columns 55 through 72 0.5347 0.0304 0.0941 0.8511 0.0878 0.7885 0.4037 0.0545 0.9211 0.1057 0.3727 0.7152 0.7221 0.7824 0.5497 0.0624 0.6367 0.6830 Columns 73 through 90 0.5039 0.9982 0.4930 0.6182 0.0806 0.1637 0.1192 0.5591 0.3517 0.3764 0.7472 0.7044 0.1543 0.4208 0.6824 0.5749 0.9823 0.1251 Columns 91 through 93 0.3348 0.0646 0.6055 y = Columns 1 through 18 0.2042 0.7205 0.0018 0.4751 0.6168 0.5327 0.6033 0.7607 0.9185 0.4314 0.3955 0.7297 0.1473 0.0513 0.7869 0.8998 0.7758 0.9592 Columns 19 through 36 0.7834 0.5294 0.9762 0.1702 0.8171 0.1715 0.2388 0.9447 0.0674 0.7837 0.9916 0.5547 0.2226 0.4250 0.5342 0.6153 0.8122 0.3594 Columns 37 through 54 0.3481 0.8889 0.3411 0.4593 0.7658 0.8746 0.8806 0.1704 0.8166 0.4705 0.3027 0.0617 0.7472 0.1019 0.4654 0.3790 0.4884 0.5347 Columns 55 through 72 0.0304 0.0941 0.8511 0.0878 0.7885 0.4037 0.0545 0.9211 0.1057 0.3727 0.7152 0.7221 0.7824 0.5497 0.0624 0.6367 0.6830 0.5039 Columns 73 through 90 0.9982 0.4930 0.6182 0.0806 0.1637 0.1192 0.5591 0.3517 0.3764 0.7472 0.7044 0.1543 0.4208 0.6824 0.5749 0.9823 0.1251 0.3348 Columns 91 through 92 0.0646 0.6055 y = Columns 1 through 18 0.2042 0.7205 0.0018 0.4751 0.6168 0.5327 0.6033 0.7607 0.9185 0.3955 0.7297 0.1473 0.0513 0.7869 0.8998 0.7758 0.9592 0.7834 Columns 19 through 36 0.5294 0.9762 0.1702 0.8171 0.1715 0.2388 0.9447 0.0674 0.7837 0.9916 0.5547 0.2226 0.4250 0.5342 0.6153 0.8122 0.3594 0.3481 Columns 37 through 54 0.8889 0.3411 0.4593 0.7658 0.8746 0.8806 0.1704 0.8166 0.4705 0.3027 0.0617 0.7472 0.1019 0.4654 0.3790 0.4884 0.5347 0.0304 Columns 55 through 72 0.0941 0.8511 0.0878 0.7885 0.4037 0.0545 0.9211 0.1057 0.3727 0.7152 0.7221 0.7824 0.5497 0.0624 0.6367 0.6830 0.5039 0.9982 Columns 73 through 90 0.4930 0.6182 0.0806 0.1637 0.1192 0.5591 0.3517 0.3764 0.7472 0.7044 0.1543 0.4208 0.6824 0.5749 0.9823 0.1251 0.3...

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 = 'Aongtimeagoinagalaxyfarfaraway' y = 'Aogtimeagoinagalaxyfarfaraway' y = 'Aogimeagoinagalaxyfarfaraway' y = 'Aogieagoinagalaxyfarfaraway' y = 'Aogiegoinagalaxyfarfaraway' y = 'Aogieginagalaxyfarfaraway' y = 'Aogiegiagalaxyfarfaraway' y = 'Aogiegiaalaxyfarfaraway' y = 'Aogiegiaaaxyfarfaraway' y = 'Aogiegiaaayfarfaraway' y = 'Aogiegiaaayarfaraway' y = 'Aogiegiaaayafaraway' y = 'Aogiegiaaayafraway' y = 'Aogiegiaaayafrway' y = 'Aogiegiaaayafrwy'