Cody

# Problem 1843. Optimally fill a container with elements of different sizes

Solution 692765

Submitted on 28 Jun 2015 by Sumit Agrawal
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
%% V = [ 0.68 0.59 2.05 2.64 2.55 1.89 2.04 1.29 1.34 0.63 ]; L = 4.63; A_correct = [ 4.62 1 ]; assert(isequal(fillitup(V,L),A_correct))

z = [] z = 0.6800 0.5900 2.0500 2.6400 2.5500 1.8900 2.0400 1.2900 1.3400 0.6300 z = 0.6800 0.5900 2.0500 2.6400 2.5500 1.8900 2.0400 1.2900 1.3400 0.6300 1.2700 2.7300 3.3200 3.2300 2.5700 2.7200 1.9700 2.0200 1.3100 2.6400 3.2300 3.1400 2.4800 2.6300 1.8800 1.9300 1.2200 4.6900 4.6000 3.9400 4.0900 3.3400 3.3900 2.6800 5.1900 4.5300 4.6800 3.9300 3.9800 3.2700 4.4400 4.5900 3.8400 3.8900 3.1800 3.9300 3.1800 3.2300 2.5200 3.3300 3.3800 2.6700 2.6300 1.9200 1.9700 z = 0.6800 0.5900 2.0500 2.6400 2.5500 1.8900 2.0400 1.2900 1.3400 0.6300 1.2700 2.7300 3.3200 3.2300 2.5700 2.7200 1.9700 2.0200 1.3100 2.6400 3.2300 3.1400 2.4800 2.6300 1.8800 1.9300 1.2200 4.6900 4.6000 3.9400 4.0900 3.3400 3.3900 2.6800 5.1900 4.5300 4.6800 3.9300 3.9800 3.2700 4.4400 4.5900 3.8400 3.8900 3.1800 3.9300 3.1800 3.2300 2.5200 3.3300 3.3800 2.6700 2.6300 1.9200 1.9700 3.3200 3.9100 3.8200 3.1600 3.3100 2.5600 2.6100 1.9000 5.3700 5.2800 4.6200 4.7700 4.0200 4.0700 3.3600 5.8700 5.2100 5.3600 4.6100 4.6600 3.9500 5.1200 5.2700 4.5200 4.5700 3.8600 4.6100 3.8600 3.9100 3.2000 4.0100 4.0600 3.3500 3.3100 2.6000 2.6500 5.2800 5.1900 4.5300 4.6800 3.9300 3.9800 3.2700 5.7800 5.1200 5.2700 4.5200 4.5700 3.8600 5.0300 5.1800 4.4300 4.4800 3.7700 4.5200 3.7700 3.8200 3.1100 3.9200 3.9700 3.2600 3.2200 2.5100 2.5600 7.2400 6.5800 6.7300 5.9800 6.0300 5.3200 6.4900 6.6400 5.8900 5.9400 5.2300 5.9800 5.2300 5.2800 4.5700 5.3800 5.4300 4.7200 4.6800 3.9700 4.0200 7.0800 7.2300 6.4800 6.5300 5.8200 6.5700 5.8200 5.8700 5.1600 5.9700 6.0200 5.3100 5.2700 4.5600 4.6100 6.4800 5.7300 5.7800 5.0700 5.8800 5.9300 5.2200 5.1800 4.4700 4.5200 5.2200 5.2700 4.5600 4.5200 3.8100 3.8600 4.6700 3.9600 4.0100 3.2600 z = 0.6800 0.5900 2.0500 2.6400 2.5500 1.8900 2.0400 1.2900 1.3400 0.6300 1.2700 2.7300 3.3200 3.2300 2.5700 2.7200 1.9700 2.0200 1.3100 2.6400 3.2300 3.1400 2.4800 2.6300 1.8800 1.9300 1.2200 4.6900 4.6000 3.9400 4.0900 3.3400 3.3900 2.6800 5.1900 4.5300 4.6800 3.9300 3.9800 3.2700 4.4400 4.5900 3.8400 3.8900 3.1800 3.9300 3.1800 3.2300 2.5200 3.3300 3.3800 2.6700 2.6300 1.9200 1.9700 3.3200 3.9100 3.8200 3.1600 3.3100 2.5600 2.6100 1.9000 5.3700 5.2800 4.6200 4.7700 4.0200 4.0700 3.3600 5.8700 5.2100 5.3600 4.6100 4.6600 3.9500 5.1200 5.2700 4.5200 4.5700 3.8600 4.6100 3.8600 3.9100 3.2000 4.0100 4.0600 3.3500 3.3100 2.6000 2.6500 5.2800 5.1900 4.5300 4.6800 3.9300 3.9800 3.2700 5.7800 5.1200 5.2700 4.5200 4.5700 3.8600 5.0300 5.1800 4.4300 4.4800 3.7700 4.5200 3.7700 3.8200 3.1100 3.9200 3.9700 3.2600 3.2200 2.5100 2.5600 7.2400 6.5800 6.7300 5.9800 6.0300 5.3200 6.4900 6.6400 5.8900 5.9400 5.2300 5.9800 5.2300 5.2800 4.5700 5.3800 5.4300 4.7200 4.6800 3.9700 4.0200 7.0800 7.2300 6.4800 6.5300 5.8200 6.5700 5.8200 5.8700 5.1600 5.9700 6.0200 5.3100 5.2700 4.5600 4.6100 6.4800 5.7300 5.7800 5.0700 5.8800 5.9300 5.2200 5.1800 4.4700 4.5200 5.2200 5.2700 4.5600 4.5200 3.8100 3.8600 4.6700 3.9600 4.0100 3.2600 5.9600 5.8700 5.2100 5.3600 4.6100 4.6600 3.9500 6.4600 5.8000 5.9500 5.2000 5.2500 4.5400 5.7100 5.8600 5.1100 5.1600 4.4500 5.2000 4.4500 4.5000 3.7900 4.6000 4.6500 3.9400 3.9000 3.1900 3.2400 7.9200 7.2600 7.4100 6.6600 6.7100 6.0000 7.1700 7.3200 6.5700 6.6200 5.9100 6.6600 5.9100 5.9600 5.2500 6.0600 6.1100 5.4000 5.3600 4.6500 4.7000 7.7600 7.9100 7.1600 7.2100 6.5000 7.2500 6.5000 6.5500 5.8400 6.6500 6.7000 5.9900 5.9500 5.2400 5.2900 7.1600 6.4100 6.4600 5.7500 6.5600 6.6100 5.9000 5.8600 5.1500 5.2000 5.9000 5.9500 5.2400 5.2000 4.4900 4.5400 5.3500 4.6400 4.6900 3.9400 7.8300 7.1700 7.3200 6.5700 6.6200 5.9100 7.0800 7.2300 6.4800 6.5300 5.8200 6.5700 5.8200 5.8700 5.1600 5.9700 6.0200 5.3100 5.2700 4.5600 4.6100 7.6700 7.8200 7.0700 7.1200 6.4100 7.1600 6.4100 6.4600 5.7500 6.5600 6.6100 5.9000 5.8600 5.1500 5.2000 7.0700 6.3200 6.3700 5.6600 6.4700 6.5200 5.8100 5.7700 5.0600 5.1100 5.8100 5.8600 5.1500 5.1100 4.4000 4.4500 5.2600 4.5500 4.6000 3.8500 9.1300 9.2800 8.5300 8.5800 7.8700 8.6200 7.8700 7.9200 7.2100 8.0200 8.0700 7.3600 7.3200 6.6100 6.6600 8.5300 7.7800 7.8300 7.1200 7.9300 7.9800 7.2700 7.2300 6.5200 6.5700 7.2700 7.3200 6.6100 6.5700 5.8600 5.9100 6.7200 6.0100 6.0600 5.3100 9.1200 8.3700 8.4200 7.7100 8.5200 8.5700 7.8600 7.8200 7.1100 7.1600 7.8600 7.9100 7.2000 7.1600 6.4500 6.5000 7.3100 6.6000 6.6500 5.9000 7.7700 7.8200 7.1100 7.0700 6.3600 6.4100 7.2200 6.5100 6.5600 5.8100 6.5600 5.8500 5.9000 5.1500 5.3000 z = 0.6800 0.5900 2.0500 2.6400 2.5500 1.8900 2.0400 1.2900 1.3400 0.6300 1.2700 2.7300 3.3200 3.2300 2.5700 2.7200 1.9700 2.0200 1.3100 2.6400 3.2300 3.1400 2.4800 2.6300 1.8800 1.9300 1.2200 4.6900 4.6000 3.9400 4.0900 3.3400 3.3900 2.6800 5.1900 4.5300 4.6800 3.9300 3.9800 3.2700 4.4400 4.5900 3.8400 3.8900 3.1800 3.9300 3.1800 3.2300 2.5200 3.3300 3.3800 2.6700 2.6300 1.9200 1.9700 3.3200 3.9100 3.8200 3.1600 3.3100 2.5600 2.6100 1.9000 5.3700 5.2800 4.6200 4.7700 4.0200 4.0700 3.3600 5.8700 5.2100 5.3600 4.6100 4.6600 3.9500 5.1200 5.2700 4.5200 4.5700 3.8600 4.6100 3.8600 3.9100 3.2000 4.0100 4.0600 3.3500 3.3100 2.6000 2.6500 5.2800 5.1900 4.5300 4.6800 3.9300 3.9800 3.2700 5.7800 5.1200 5.2700 4.5200 4.5700 3.8600 5.0300 5.1800 4.4300 4.4800 3.7700 4.5200 3.7700 3.8200 3.1100 3.9200 3.9700 3.2600 3.2200 2.5100 2.5600 7.2400 6.5800 6.7300 5.9800 6.0300 5.3200 6.4900 6.6400 5.8900 5.9400 5.2300 5.9800 5.2300 5.2800 4.5700 5.3800 5.4300 4.7200 4.6800 3.9700 4.0200 7.0800 7.2300 6.4800 6.5300 5.8200 6.5700 5.8200 5.8700 5.1600 5.9700 6.0200 5.3100 5.2700 4.5600 4.6100 6.4800 5.7300 5.7800 5.0700 5.8800 5.9300 5.2200 5.1800 4.4700 4.5200 5.2200 5.2700 4.5600 4.5200 3.8100 3.8600 4.6700 3.9600 4.0100 3.2600 5.9600 5.8700 5.2100 5.3600 4.6100 4.6600 3.9500 6.4600 5.8000 5.9500 5.2000 5.2500 4.5400 5.7100 5.8600 5.1100 5.1600 4.4500 5.2000 4.4500 4.5000 3.7900 4.6000 4.6500 3.9400 3.9000 3.1900 3.2400 7.9200 7.2600 7.4100 6.6600 6.7100 6.0000 7.1700 7.3200 6.5700 6.6200 5.9100 6.6600 5.9100 5.9600 5.2500 6.0600 6.1100 5.4000 5.3600 4.6500 4.7000 7.7600 7.9100 7.1600 7.2100 6.5000 7.2500 6.5000 6.5500 5.8400 6.6500 6.7000 5.9900 5.9500 5.2400 5.2900 7.1600 6.4100 6.4600 5.7500 6.5600 6.6100 5.9000 5.8600 5.1500 5.2000 5.9000 5.9500 5.2400 5.2000 4.4900 4.5400 5.3500 4.6400 4.6900 3.9400 7.8300 7.1700 7.3200 6.5700 6.6200 5.9100 7.0800 7.2300 6.4800 6.5300 5.8200 6.5700 5.8200 5.8700 5.1600 5.9700 6.0200 5.3100 5.2700 4.5600 4.6100 7.6700 ...

2   Pass
%% V = [ 51 98 64 21 3 12 16 10 31 81 ]; L = 108; A_correct = [ 108 3 ]; assert(isequal(fillitup(V,L),A_correct))

z = [] z = 51 98 64 21 3 12 16 10 31 81 z = 51 98 64 21 3 12 16 10 31 81 149 115 72 54 63 67 61 82 132 162 119 101 110 114 108 129 179 85 67 76 80 74 95 145 24 33 37 31 52 102 15 19 13 34 84 28 22 43 93 26 47 97 41 91 112 z = 51 98 64 21 3 12 16 10 31 81 149 115 72 54 63 67 61 82 132 162 119 101 110 114 108 129 179 85 67 76 80 74 95 145 24 33 37 31 52 102 15 19 13 34 84 28 22 43 93 26 47 97 41 91 112 213 170 152 161 165 159 180 230 136 118 127 131 125 146 196 75 84 88 82 103 153 66 70 64 85 135 79 73 94 144 77 98 148 92 142 163 183 165 174 178 172 193 243 122 131 135 129 150 200 113 117 111 132 182 126 120 141 191 124 145 195 139 189 210 88 97 101 95 116 166 79 83 77 98 148 92 86 107 157 90 111 161 105 155 176 36 40 34 55 105 49 43 64 114 47 68 118 62 112 133 31 25 46 96 29 50 100 44 94 115 38 59 109 53 103 124 57 107 128 122 z = 51 98 64 21 3 12 16 10 31 81 149 115 72 54 63 67 61 82 132 162 119 101 110 114 108 129 179 85 67 76 80 74 95 145 24 33 37 31 52 102 15 19 13 34 84 28 22 43 93 26 47 97 41 91 112 213 170 152 161 165 159 180 230 136 118 127 131 125 146 196 75 84 88 82 103 153 66 70 64 85 135 79 73 94 144 77 98 148 92 142 163 183 165 174 178 172 193 243 122 131 135 129 150 200 113 117 111 132 182 126 120 141 191 124 145 195 139 189 210 88 97 101 95 116 166 79 83 77 98 148 92 86 107 157 90 111 161 105 155 176 36 40 34 55 105 49 43 64 114 47 68 118 62 112 133 31 25 46 96 29 50 100 44 94 115 38 59 109 53 103 124 57 107 128 122 234 216 225 229 223 244 294 173 182 186 180 201 251 164 168 162 183 233 177 171 192 242 175 196 246 190 240 261 139 148 152 146 167 217 130 134 128 149 199 143 137 158 208 141 162 212 156 206 227 87 91 85 106 156 100 94 115 165 98 119 169 113 163 184 82 76 97 147 80 101 151 95 145 166 89 110 160 104 154 175 108 158 179 173 186 195 199 193 214 264 177 181 175 196 246 190 184 205 255 188 209 259 203 253 274 134 138 132 153 203 147 141 162 212 145 166 216 160 210 231 129 123 144 194 127 148 198 142 192 213 136 157 207 151 201 222 155 205 226 220 100 104 98 119 169 113 107 128 178 111 132 182 126 176 197 95 89 110 160 93 114 164 108 158 179 102 123 173 117 167 188 121 171 192 186 52 46 67 117 50 71 121 65 115 136 59 80 130 74 124 145 78 128 149 143 41 62 112 56 106 127 60 110 131 125 69 119 140 134 138 z = 51 98 64 21 3 12 16 10 31 81 149 115 72 54 63 67 61 82 132 162 119 101 110 114 108 129 179 85 67 76 80 74 95 145 24 33 37 31 52 102 15 19 13 34 84 28 22 43 93 26 47 97 41 91 112 213 170 152 161 165 159 180 230 136 118 127 131 125 146 196 75 84 88 82 103 153 66 70 64 85 135 79 73 94 144 77 98 148 92 142 163 183 165 174 178 172 193 243 122 131 135 129 150 200 113 117 111 132 182 126 120 141 191 124 145 195 139 189 210 88 97 101 95 116 166 79 83 77 98 148 92 86 107 157 90 111 161 105 155 176 36 40 34 55 105 49 43 64 114 47 68 118 62 112 133 31 25 46 96 29 50 100 44 94 115 38 59 109 53 103 124 57 107 128 122 234 216 225 229 223 244 294 173 182 186 180 201 251 164 168 162 183 233 177 171 192 242 175 196 246 190 240 261 139 148 152 146 167 217 130 134 128 149 199 143 137 158 208 141 162 212 156 206 227 87 91 85 106 156 100 94 115 165 98 119 169 113 163 184 82 76 97 147 80 101 151 95 145 166 89 110 160 104 154 175 108 158 179 173 186 195 199 193 214 264 177 181 175 196 246 190 184 205 255 188 209 259 203 253 274 134 138 132 153 203 147 141 162 212 145 166 216 160 210 231 129 123 144 194 127 148 198 142 192 213 136 157 207 151 201 222 155 205 226 220 100 104 98 119 169 113 107 128 178 111 132 182 126 176 197 95 89 110 160 93 114 164 108 158 179 102 123 173 117 167 188 121 171 192 186 52 46 67 117 50 71 121 65 115 136 59 80 130 74 124 145 78 128 149 143 41 62 112 56 106 127 60 110 131 125 69 119 140 134 138 237 246 250 244 265 315 228 232 226 247 297 241 235 256 306 239 260 310 254 304 325 185 189 183 204 254 198 192 213 263 196 217 267 211 261 282 180 174 195 245 178 199 249 193 243 264 187 208 258 202 252 273 206 256 277 271 151 155 149 170 220 164 158 179 229 162 183 233 177 227 248 146 140 161 211 144 165 215 159 209 230 153 174 224 168 218 239 172 222 243 237 103 97 118 168 101 122 172 116 166 187 110 131 181 125 175 196 129 179 200 194 92 113 163 107 157 178 111 161 182 176 120 170 191 185 189 198 202 196 217 267 211 205 226 276 209 230 280 224 274 295 193 187 208 258 191 212 262 206 256 277 200 221 271 215 265 286 219 269 290 284 150 144 165 215 148 169 219 163 213 234 157 178 228 172 222 243 176 226 247 241 139 160 210 154 204 225 158 208 229 223 167 217 238 232 236 116 110 131 181 114 135 185 129 179 200 123 144 194 138 188 209 142 192 213 207 105 126 176 120 170 191 124 174 195 189 133 183 204 198 202 62 83 133 77 127 148 81 131 152 146 90 140 161 155 159 72 122 143 137 141 150 z = 51 98 64 21 3 12 16 10 31 81 149 115 72 54 63 67 61 82 132 162 119 101 110 114 108 129 179 85 67 76 80 74 95 145 24 33 37 31 52 102 15 19 13 34 84 28 22 43 93 26 47 97 41 91 112 213 170 152 161 165 159 180 230 136 118 127 131 125 146 196 75 84 88 82 103 153 66 70 64 85 135 79 73 94 144 77 98 148 92 142 163 183 165 174 178 172 193 243 122 131 135 129 150 200 113 117 111 132 182 126 120 141 191 124 145 195 139 189 210 88 97 101 95 116 166 79 83 77 98 148 92 86 107 157 90 111 161 105 155 176 36 40 34 55 105 49 43 64 114 47 68 118 62 112 133 31 25 46 96 29 50 ...

3   Fail

### Community Treasure Hunt

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

Start Hunting!