Cody

Problem 2545. compress sequence into intervals

Solution 2026643

Submitted on 18 Nov 2019 at 16:57
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))

a = 1 2 a = 1 2 3 a = 1 2 3 4 a = 1 2 3 4 5 y = 1 5 a = [] a = 7 8 a = 7 8 9 y = 1 5 7 9 a = [] a = 24 25 a = 24 25 26 a = 24 25 26 27 a = 24 25 26 27 28 a = 24 25 26 27 28 29 a = 24 25 26 27 28 29 30 a = 24 25 26 27 28 29 30 31 a = 24 25 26 27 28 29 30 31 32 y = 1 5 7 9 24 32 a = [] bounds = 1 5 7 9 24 32

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

a = 100 101 a = 100 101 102 a = 100 101 102 103 a = 100 101 102 103 104 a = 100 101 102 103 104 105 a = 100 101 102 103 104 105 106 a = 100 101 102 103 104 105 106 107 a = 100 101 102 103 104 105 106 107 108 a = 100 101 102 103 104 105 106 107 108 109 a = 100 101 102 103 104 105 106 107 108 109 110 a = 100 101 102 103 104 105 106 107 108 109 110 111 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 a = 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Column 30 129 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 31 129 130 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 32 129 130 131 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 33 129 130 131 132 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 34 129 130 131 132 133 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 35 129 130 131 132 133 134 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 36 129 130 131 132 133 134 135 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 37 129 130 131 132 133 134 135 136 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 38 129 130 131 132 133 134 135 136 137 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 39 129 130 131 132 133 134 135 136 137 138 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 40 129 130 131 132 133 134 135 136 137 138 139 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 41 129 130 131 132 133 134 135 136 137 138 139 140 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 42 129 130 131 132 133 134 135 136 137 138 139 140 141 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 43 129 130 131 132 133 134 135 136 137 138 139 140 141 142 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 44 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 45 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 46 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 47 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 48 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 49 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 50 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 51 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 Columns 30 through 52 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 a = Columns 1 through 29 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 ...

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

a = -10 -9 a = -10 -9 -8 a = -10 -9 -8 -7 a = -10 -9 -8 -7 -6 a = -10 -9 -8 -7 -6 -5 a = -10 -9 -8 -7 -6 -5 -4 a = -10 -9 -8 -7 -6 -5 -4 -3 a = -10 -9 -8 -7 -6 -5 -4 -3 -2 a = -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 a = -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 a = -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 a = -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 a = -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 a = -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 a = -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 a = -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 a = -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 a = -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 a = -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 a = -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 y = -10 10 a = [] bounds = -10 10

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

y = [] a = [] y = [] a = [] bounds = []

Assertion failed.

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

y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] y = [] a = [] bounds = []

Assertion failed.