Cody

Solution 1928778

Submitted on 10 Sep 2019
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))

l = 5 8 l = 5 6 8 9 bounds = 1 5 7 9 24 32

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

l = 101 l = 1 101 102 202 bounds = 100 200 300 400

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

l = 1×0 empty double row vector bounds = 1×0 empty double row vector bounds = -10 10

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

l = [] bounds = [] bounds = 9 11

Assertion failed.

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

l = 1×0 empty double row vector bounds = 1×0 empty double row vector bounds = Columns 1 through 30 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 31 through 50 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99

Assertion failed.