Cody

# Problem 44952. Find MPG of Lightest Cars

Solution 2753923

Submitted on 29 Jul 2020 by Sergio Enrique Pinto Castillo
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
N = 5 load(fullfile(matlabroot, 'toolbox/stats/statsdemos', 'carbig.mat')); Model = strtrim(string(Model)); cars = table(Model, MPG, Horsepower, Weight, Acceleration); save cars.mat cars assert(isequal(sort_cars(N),[35; 31; 39.1; 35.1; 31]));

N = 5 Weightorder = 1613 1649 1755 1760 1773 1795 1795 1800 1800 1825 1825 1834 1835 1835 1836 1845 1850 1867 1875 1915 1925 1937 1937 1940 1945 1950 1950 1955 1963 1965 1965 1968 1970 1975 1975 1978 1980 1985 1985 1985 1985 1990 1990 1995 2000 2003 2019 2020 2025 2035 2045 2045 2046 2050 2051 2065 2065 2070 2074 2075 2085 2100 2108 2110 2110 2120 2123 2124 2125 2125 2125 2126 2130 2130 2130 2130 2135 2144 2145 2150 2155 2155 2155 2158 2160 2164 2164 2171 2188 2189 2190 2190 2200 2202 2205 2210 2215 2219 2220 2220 2223 2226 2228 2230 2234 2245 2246 2254 2255 2264 2265 2265 2265 2278 2279 2288 2290 2295 2300 2300 2300 2310 2320 2330 2335 2350 2370 2372 2375 2379 2380 2385 2391 2395 2395 2401 2405 2408 2408 2420 2430 2434 2451 2464 2472 2489 2490 2500 2506 2511 2515 2525 2542 2542 2545 2556 2560 2565 2572 2575 2582 2585 2587 2592 2595 2600 2605 2615 2620 2625 2634 2635 2635 2639 2640 2648 2660 2665 2670 2670 2671 2672 2678 2694 2700 2702 2711 2720 2720 2720 2725 2735 2740 2745 2755 2774 2789 2790 2795 2800 2800 2807 2815 2830 2833 2835 2855 2865 2868 2870 2875 2890 2900 2901 2904 2905 2910 2914 2930 2930 2933 2945 2945 2945 2950 2950 2957 2962 2965 2979 2984 2990 3003 3012 3015 3021 3035 3039 3060 3070 3085 3086 3090 3102 3121 3139 3140 3150 3155 3158 3160 3169 3190 3193 3205 3210 3211 3221 3230 3233 3245 3250 3264 3265 3270 3278 3282 3288 3302 3329 3336 3353 3353 3360 3365 3380 3381 3399 3410 3410 3415 3420 3425 3425 3430 3432 3433 3436 3439 3445 3449 3459 3465 3504 3520 3525 3530 3535 3563 3570 3574 3605 3609 3613 3620 3630 3632 3645 3651 3664 3672 3672 3693 3725 3725 3730 3735 3755 3761 3777 3781 3785 3820 3821 3830 3840 3850 3850 3870 3880 3892 3897 3900 3907 3940 3940 3955 3962 3988 4034 4042 4054 4055 4060 4077 4080 4082 4096 4098 4100 4129 4135 4140 4141 4142 4154 4165 4166 4190 4209 4215 4215 4220 4237 4257 4274 4278 4294 4295 4312 4325 4335 4341 4354 4360 4363 4376 4380 4382 4385 4422 4425 4440 4456 4457 4464 4464 4498 4499 4502 4615 4633 4638 4654 4657 4668 4699 4732 4735 4746 4906 4951 4952 4955 4997 5140 Index = 62 152 351 353 61 189 206 253 256 211 226 63 26 338 139 340 337 125 352 303 301 183 205 241 228 110 137 64 150 392 393 318 386 302 355 40 384 247 252 254 357 212 286 394 159 153 320 311 385 203 224 359 39 356 245 60 354 255 59 246 333 92 155 330 332 319 58 119 154 387 388 66 25 36 312 403 287 317 339 310 213 225 274 126 389 91 204 175 325 87 248 361 309 194 390 363 358 149 57 191 180 69 38 277 30 391 156 67 193 37 122 243 329 65 116 89 345 404 151 227 276 120 362 79 334 364 400 21 29 118 360 350 158 88 378 117 281 54 68 342 28 328 138 190 121 157 346 343 90 85 278 380 140 327 181 316 275 214 192 379 127 397 24 178 314 250 376 365 348 405 41 347 366 176 377 31 130 399 304 313 188 27 321 185 315 179 326 251 263 406 349 381 242 279 244 23 115 402 284 331 368 131 249 282 22 398 280 382 128 322 134 290 370 135 109 344 341 177 218 371 84 107 187 395 335 401 186 53 262 86 182 289 323 201 396 108 383 172 374 267 202 20 11 133 105 56 283 215 261 163 369 174 307 210 272 265 184 173 367 199 288 336 160 291 217 106 55 45 44 43 136 18 200 292 257 266 324 129 269 285 372 308 234 270 264 162 4 3 42 271 5 161 375 1 233 236 305 260 16 259 208 299 17 143 268 235 142 209 207 132 74 94 2 294 373 170 258 223 19 97 141 171 219 104 296 293 10 15 222 229 80 169 306 168 216 300 295 197 95 13 96 298 221 230 83 273 123 49 81 93 73 72 231 144 12 48 238 14 196 46 195 198 237 101 148 70 124 82 232 8 239 240 6 7 297 100 33 220 34 71 78 9 165 77 146 47 99 166 114 76 32 75 147 113 167 164 145 35 102 51 112 103 98 50 111 52 mpg1 = 35 mpg1 = 35 31 mpg1 = 35.0000 31.0000 39.1000 mpg1 = 35.0000 31.0000 39.1000 35.1000 mpg1 = 35.0000 31.0000 39.1000 35.1000 31.0000

2   Pass
N = 6 load(fullfile(matlabroot, 'toolbox/stats/statsdemos', 'carsmall.mat')); Model = strtrim(string(Model)); cars = table(Model, MPG, Horsepower, Weight, Acceleration); save cars.mat cars assert(isequal(sort_cars(N),[33; 29.5; 26; 29; 38; 32]));

N = 6 Weightorder = 1795 1825 1835 1937 1965 1965 1970 1980 1990 1995 2025 2035 2125 2125 2130 2130 2155 2160 2164 2202 2205 2220 2234 2245 2255 2295 2370 2372 2375 2395 2430 2464 2525 2565 2572 2575 2585 2587 2605 2625 2640 2648 2665 2672 2720 2735 2774 2790 2833 2835 2865 2930 2945 2950 3012 3015 3035 3085 3086 3090 3150 3193 3233 3270 3353 3353 3433 3436 3449 3504 3563 3574 3609 3645 3651 3693 3755 3761 3820 3850 3850 3870 3940 3962 4034 4055 4142 4166 4190 4215 4215 4312 4341 4354 4376 4380 4382 4425 4615 4732 Index = 52 57 26 51 86 87 80 78 58 88 79 49 81 82 25 97 59 83 50 40 84 37 30 85 39 98 94 21 29 72 28 36 74 60 38 73 91 24 70 99 71 31 93 27 100 75 23 96 22 92 76 64 89 95 47 90 77 48 20 11 61 56 45 63 18 46 4 3 5 1 16 54 17 55 53 2 69 19 65 10 15 68 62 43 13 67 12 14 42 41 44 8 6 7 33 66 34 9 32 35 mpg1 = 33 mpg1 = 33.0000 29.5000 mpg1 = 33.0000 29.5000 26.0000 mpg1 = 33.0000 29.5000 26.0000 29.0000 mpg1 = 33.0000 29.5000 26.0000 29.0000 38.0000 mpg1 = 33.0000 29.5000 26.0000 29.0000 38.0000 32.0000

### Community Treasure Hunt

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

Start Hunting!