Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 357415

Submitted on 21 Nov 2013

Incorrect

35Size
Leading solution size is 27.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Fail
 
%%
x = [1 0 0 2 0];
y_correct = [1 1 1 2 2];
assert(isequal(bleed_to_the_right(x),y_correct))
filetext = fileread('bleed_to_the_right.m');
assert(isempty(strfind(filetext, 'regexp')),'regexp* command is forbidden')
assert(isempty(strfind(filetext, 'eval')),'eval* command is forbidden')
assert(isempty(strfind(filetext, 'inline')),'inline command is forbidden')
Error: Assertion failed.
2
Fail
 
%%
x = [0 0 -12 13 0 i 0 -i 76.54321 0 0];
y_correct = [0 0 -12 13 13 i i -i 76.54321 76.54321 76.54321];
assert(isequal(bleed_to_the_right(x),y_correct))
Error: Assertion failed.
3
Fail
 
%%
x = [1:100 0];
y_correct = [1:100 100];
assert(isequal(bleed_to_the_right(x),y_correct))
Error: Assertion failed.
4
Fail
 
%%
x = rand(1,1000);
x(randi(500,1,50)*2) = 0;
y_correct = x;
y_correct(~y_correct) = y_correct(find(~y_correct)-1);
assert(isequal(bleed_to_the_right(x),y_correct))
Error: Assertion failed.
5
Fail
 
%%
x = sqrt(1:100);
y_correct = floor(x);
x(x~=floor(x)) = 0;
assert(isequal(bleed_to_the_right(x),y_correct))
Error: Assertion failed.