Cody

# Problem 42832. Segmented number sequence

Solution 2638360

Submitted on 1 Jul 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   Pass
n = 12; x = [2 3]; v_correct = [1 2 4 5 8 10 12 14 15 16 19 20]; assert(isequal(segnum(n,x),v_correct))

v = 1 2 4 5 8 10 12 14 15 16 19 20

2   Fail
n = 22; x = 0; v_correct = [1 2 4 5 8 10 14 15 16 21 22 25 26 28 33 34 35 36 38 40 42 46]; assert(isequal(segnum(n,x),v_correct))

Index exceeds the number of array elements (4). Error in segnum (line 19) v=v(1:n) Error in Test2 (line 4) assert(isequal(segnum(n,x),v_correct))

3   Pass
n = 15; x = [2 4]; v_correct = [1 2 4 5 7 8 10 11 13 14 16 17 19 20 22]; assert(isequal(segnum(n,x),v_correct))

v = 1 2 4 5 7 8 10 11 13 14 16 17 19 20 22

4   Fail
n = 23; x = [2 3 5 6]; v_correct = [1 2 4 5 8 10 12 14 15 16 19 21 24 25 27 28 32 33 34 37 38 42 43]; assert(isequal(segnum(n,x),v_correct))

v = 1 2 4 5 8 10 12 14 15 v = 1 2 4 5 8 10 12 14 15 16 19 21 24 25 27 28 31 32 33 34 35 37 38

Assertion failed.

### Community Treasure Hunt

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

Start Hunting!