Cody

# Problem 2545. compress sequence into intervals

Solution 2570688

Submitted on 17 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
sequence = [1 2 3 4 5 7 8 9 24 25 26 27 28 29 30 31 32]; bounds = [1 5 7 9 24 32]; assert(isequal(CompressSequence(sequence), bounds))

Index exceeds the number of array elements (17). Error in CompressSequence (line 8) if sequence(j)+1==sequence(j+1) Error in Test1 (line 3) assert(isequal(CompressSequence(sequence), bounds))

2   Fail
sequence = [100:200 300:400]; bounds = [100 200 300 400]; assert(isequal(CompressSequence(sequence), bounds))

Index exceeds the number of array elements (202). Error in CompressSequence (line 8) if sequence(j)+1==sequence(j+1) Error in Test2 (line 3) assert(isequal(CompressSequence(sequence), bounds))

3   Fail
sequence = -10:10; bounds = [-10 10]; assert(isequal(CompressSequence(sequence), bounds))

Index exceeds the number of array elements (21). Error in CompressSequence (line 8) if sequence(j)+1==sequence(j+1) Error in Test3 (line 3) assert(isequal(CompressSequence(sequence), bounds))

4   Fail
sequence = [9 11]; bounds = [9 9 11 11]; assert(isequal(CompressSequence(sequence), bounds))

Index exceeds the number of array elements (2). Error in CompressSequence (line 8) if sequence(j)+1==sequence(j+1) Error in Test4 (line 3) assert(isequal(CompressSequence(sequence), bounds))

5   Fail
sequence = 1:2:99; temp = [1:2:99; 1:2:99]; bounds = temp(:)'; assert(isequal(CompressSequence(sequence), bounds))

Index exceeds the number of array elements (50). Error in CompressSequence (line 8) if sequence(j)+1==sequence(j+1) Error in Test5 (line 4) assert(isequal(CompressSequence(sequence), bounds))

### Community Treasure Hunt

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

Start Hunting!