Cody

Problem 1779. Oh Zero Zero Zero!!!

Solution 2967601

Submitted on 19 Sep 2020 by Jimmy Sølvsteen Nielsen
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 no sequence 0000 no sequence 0000 no sequence 0000 no sequence 0000 no sequence 0000 no sequence 0000 no sequence 0000 no sequence 0000 new sequence 0000 currPos = 10 in sequence 00110 in sequence 00210 in sequence 00310 in sequence 00410 in sequence 00510 in sequence 00610 in sequence 00710 in sequence 00810 end of sequence 00910 no sequence 910010 no sequence 910010 no sequence 910010 no sequence 910010 no sequence 910010 no sequence 910010 no sequence 910010 no sequence 910010 910010

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 new sequence 0000 currPos = 2 end of sequence 0012 no sequence 1202 no sequence 1202 no sequence 1202 no sequence 1202 no sequence 1202 new sequence 1202 currPos = 9 in sequence 1219 in sequence 1229 in sequence 1239 in sequence 1249 in sequence 1259 end of sequence 1269 no sequence 6909 new sequence 6909 currPos = 17 in sequence 69117 in sequence 69217 end of sequence 69317 no sequence 69017 no sequence 69017 69017

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

no sequence 0000 new sequence 0000 currPos = 3 in sequence 0013 in sequence 0023 in sequence 0033 in sequence 0043 in sequence 0053 in sequence 0063 end of sequence 0073 no sequence 7303 no sequence 7303 no sequence 7303 no sequence 7303 no sequence 7303 new sequence 7303 currPos = 16 73116

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

LP = 2 3 no sequence 0000 new sequence 0000 currPos = 3 in sequence 0013 2323

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 no sequence 0000 new sequence 0000 currPos = 3 in sequence 0013 in sequence 0023 in sequence 0033 in sequence 0043 in sequence 0053 in sequence 0063 in sequence 0073 in sequence 0083 end of sequence 0093 new sequence 9303 currPos = 13 in sequence 93113 in sequence 93213 in sequence 93313 in sequence 93413 in sequence 93513 93613

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 new sequence 0000 currPos = 2 in sequence 0012 in sequence 0022 in sequence 0032 in sequence 0042 in sequence 0052 in sequence 0062 in sequence 0072 in sequence 0082 end of sequence 0092 9202

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 no sequence 0000 new sequence 0000 currPos = 3 end of sequence 0013 no sequence 1303 new sequence 1303 currPos = 6 in sequence 1316 in sequence 1326 end of sequence 1336 no sequence 3606 new sequence 3606 currPos = 11 end of sequence 36111 no sequence 36011 no sequence 36011 no sequence 36011 new sequence 36011 currPos = 16 end of sequence 36116 36016

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

LP = 1 2 new sequence 0000 currPos = 2 end of sequence 0012 1202

Suggested Problems

More from this Author17

Community Treasure Hunt

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

Start Hunting!