This solution is wrong. even if it is considered correct. This solution would eliminate elements with value equal to 0 as well.
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.4713 0.5222 0.6567 0.3563 0.5649
|
2 | Pass |
x = rand(1,100);
actual = everyOther(x);
expected = x(1:2:length(x));
assert(isequal(actual, expected))
y =
Columns 1 through 9
0.1915 0.0880 0.1132 0.9461 0.7170 0.1426 0.9873 0.4565 0.9513
Columns 10 through 18
0.3076 0.8901 0.8901 0.0942 0.8291 0.7671 0.3398 0.5173 0.0425
Columns 19 through 27
0.7741 0.1504 0.5396 0.9797 0.8344 0.4161 0.9172 0.4975 0.4307
Columns 28 through 36
0.3762 0.9855 0.9402 0.5761 0.2725 0.2772 0.5330 0.7316 0.8864
Columns 37 through 45
0.4566 0.5977 0.5254 0.5101 0.0983 0.8137 0.2753 0.4391 0.0384
Columns 46 through 50
0.8588 0.4730 0.9140 0.5198 0.3125
|
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 =
Aogiegiaaayafrwy
|
9875 Solvers
1262 Solvers
405 Solvers
Given a 4x4 matrix, swap the two middle columns
516 Solvers
274 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!