Cody

Problem 44058. No more zeros

Solution 2233422

Submitted on 25 Apr 2020
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   Fail
a = zeros(5,1); b = [1 2 5 1 0 2 5 80]'; x = [a; b]; y_correct = b; assert(isequal(without_zeros(x),y_correct))

Unrecognized function or variable 'y'. Error in without_zeros (line 2) n=find(y~=0); Error in Test1 (line 5) assert(isequal(without_zeros(x),y_correct))

2   Fail
a = rand(1,10)+1; b = zeros(1,3); x = [a b]; y_correct = a; assert(isequal(without_zeros(x),y_correct))

Unrecognized function or variable 'y'. Error in without_zeros (line 2) n=find(y~=0); Error in Test2 (line 5) assert(isequal(without_zeros(x),y_correct))

3   Fail
x = 0:10; y_correct = 1:10; assert(isequal(without_zeros(x),y_correct))

Unrecognized function or variable 'y'. Error in without_zeros (line 2) n=find(y~=0); Error in Test3 (line 3) assert(isequal(without_zeros(x),y_correct))

4   Fail
a = 0:10; b = 1:10; x = [a zeros(1,5) fliplr(a)]; y_correct = [b zeros(1,5) fliplr(b)]; assert(isequal(without_zeros(x),y_correct))

Unrecognized function or variable 'y'. Error in without_zeros (line 2) n=find(y~=0); Error in Test4 (line 5) assert(isequal(without_zeros(x),y_correct))

5   Fail
x = [0 0 0 0 1 0 0]; y_correct = 1; assert(isequal(without_zeros(x),y_correct))

Unrecognized function or variable 'y'. Error in without_zeros (line 2) n=find(y~=0); Error in Test5 (line 3) assert(isequal(without_zeros(x),y_correct))

6   Fail
x = [1 0 0 0 0 0 0]; y_correct = 1; assert(isequal(without_zeros(x),y_correct))

Unrecognized function or variable 'y'. Error in without_zeros (line 2) n=find(y~=0); Error in Test6 (line 3) assert(isequal(without_zeros(x),y_correct))