Cody

Solution 2254148

Submitted on 4 May 2020 by Juan Berjón
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 = [1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 0 0 0 9 8 7 6 5 4 3 2 1]; LP = [9 10] %[Length Position] assert(isequal(LengthAndPosnZeros(x),LP))

LP = 9 10 non_zero = 0 1 2 3 4 5 6 7 8 9 19 20 21 22 23 24 25 26 27 28 dist_non_zero = 0 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 i = 10 j = 11 y = 9 10

2   Pass
x = [1 0 3 49 3 2 232 3 0 0 0 0 0 0 8 290 0 0 0 12 323 34]; LP = [6 9] assert(isequal(LengthAndPosnZeros(x),LP))

LP = 6 9 non_zero = 0 1 3 4 5 6 7 8 15 16 20 21 22 23 dist_non_zero = 0 1 2 1 1 1 1 1 7 1 4 1 1 1 i = 7 j = 9 y = 6 9

3   Pass
x = [1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 0]; LP = [7 3]; assert(isequal(LengthAndPosnZeros(x),LP))

non_zero = 0 1 2 10 11 12 13 14 15 17 dist_non_zero = 0 1 1 8 1 1 1 1 1 2 i = 8 j = 4 y = 7 3

4   Pass
x = [1 2 0 0]; LP = [2 3] %[Length Position] assert(isequal(LengthAndPosnZeros(x),LP))

LP = 2 3 non_zero = 0 1 2 5 dist_non_zero = 0 1 1 3 i = 3 j = 4 y = 2 3

5   Pass
x = [1 2 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0]; LP = [9 3] %[Length Position] assert(isequal(LengthAndPosnZeros(x),LP))

LP = 9 3 non_zero = 0 1 2 12 19 dist_non_zero = 0 1 1 10 7 i = 10 j = 4 y = 9 3

6   Pass
x = [1 0 0 0 0 0 0 0 0 0 1]; LP = [9 2] %[Length Position] assert(isequal(LengthAndPosnZeros(x),LP))

LP = 9 2 non_zero = 0 1 11 12 dist_non_zero = 0 1 10 1 i = 10 j = 3 y = 9 2

7   Pass
x = [111 541 0 45 3 0 0 0 15 26 0 4 84 3 84 0 9]; LP = [3 6] %[Length Position] assert(isequal(LengthAndPosnZeros(x),LP))

LP = 3 6 non_zero = 0 1 2 4 5 9 10 12 13 14 15 17 18 dist_non_zero = 0 1 1 2 1 4 1 2 1 1 1 2 1 i = 4 j = 6 y = 3 6

8   Pass
x = [1 0 1]; LP = [1 2] %[Length Position] assert(isequal(LengthAndPosnZeros(x),LP))

LP = 1 2 non_zero = 0 1 3 4 dist_non_zero = 0 1 2 1 i = 2 j = 3 y = 1 2