Cody

# Problem 2545. compress sequence into intervals

Solution 1666714

Submitted on 6 Nov 2018 by Augusto Mazzei
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
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))

ans = 5 8 6 9 ans = 1 5 7 9 24 32

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

ans = 101 102 ans = 100 200 300 400

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

ans = 1×0 empty double row vector ans = -10 10

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

ans = 1 2 ans = 9 9 11 11

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

ans = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 30 through 58 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 2 3 4 5 6 7 8 9 10 Columns 59 through 87 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 Columns 88 through 98 40 41 42 43 44 45 46 47 48 49 50 ans = Columns 1 through 29 1 1 3 3 5 5 7 7 9 9 11 11 13 13 15 15 17 17 19 19 21 21 23 23 25 25 27 27 29 Columns 30 through 58 29 31 31 33 33 35 35 37 37 39 39 41 41 43 43 45 45 47 47 49 49 51 51 53 53 55 55 57 57 Columns 59 through 87 59 59 61 61 63 63 65 65 67 67 69 69 71 71 73 73 75 75 77 77 79 79 81 81 83 83 85 85 87 Columns 88 through 100 87 89 89 91 91 93 93 95 95 97 97 99 99

### Community Treasure Hunt

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

Start Hunting!