Cody

# Problem 44058. No more zeros

Solution 3813858

Submitted on 24 Nov 2020 by Akrem Hadji
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
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))

x = 0 0 0 0 1 2 5 1 0 2 5 80 x = 0 0 0 1 2 5 1 0 2 5 80 x = 0 0 1 2 5 1 0 2 5 80 x = 0 1 2 5 1 0 2 5 80 x = 1 2 5 1 0 2 5 80

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

x = 1.4221 1.0703 1.9502 1.5630 1.6115 1.2164 1.5867 1.4955 1.7999 1.5344 0 0 x = 1.4221 1.0703 1.9502 1.5630 1.6115 1.2164 1.5867 1.4955 1.7999 1.5344 0 x = 1.4221 1.0703 1.9502 1.5630 1.6115 1.2164 1.5867 1.4955 1.7999 1.5344

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

x = 1 2 3 4 5 6 7 8 9 10

4   Pass
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))

x = 1 2 3 4 5 6 7 8 9 10 0 0 0 0 0 10 9 8 7 6 5 4 3 2 1 0 x = 1 2 3 4 5 6 7 8 9 10 0 0 0 0 0 10 9 8 7 6 5 4 3 2 1

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

x = 0 0 0 1 0 0 x = 0 0 1 0 0 x = 0 1 0 0 x = 1 0 0 x = 1 0 x = 1

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

x = 1 0 0 0 0 0 x = 1 0 0 0 0 x = 1 0 0 0 x = 1 0 0 x = 1 0 x = 1

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!