Cody

Problem 42832. Segmented number sequence

Solution 2635897

Submitted on 30 Jun 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
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))

s = 3 4 5 6 7 8 9 10 11 ans = 1×9 logical array 1 0 0 1 1 0 1 0 1

Assertion failed.

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

s = 0 ans = logical 1

Assertion failed.

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

s = 3 4 5 6 7 8 9 10 11 12 ans = 1×10 logical array 1 0 0 1 0 0 1 0 0 1

Assertion failed.

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

s = 3 4 5 6 7 8 9 10 11 ans = 1×9 logical array 1 0 0 1 1 0 1 0 1

Assertion failed.