Cody

# Problem 44952. Find MPG of Lightest Cars

Solution 1980038

Submitted on 17 Oct 2019 by ME
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 cars = 1.0e+03 * 0.0180 3.5040 0.0150 3.6930 0.0180 3.4360 0.0160 3.4330 0.0170 3.4490 0.0150 4.3410 0.0140 4.3540 0.0140 4.3120 0.0140 4.4250 0.0150 3.8500 NaN 3.0900 NaN 4.1420 NaN 4.0340 NaN 4.1660 NaN 3.8500 0.0150 3.5630 0.0140 3.6090 NaN 3.3530 0.0150 3.7610 0.0140 3.0860 0.0240 2.3720 0.0220 2.8330 0.0180 2.7740 0.0210 2.5870 0.0270 2.1300 0.0260 1.8350 0.0250 2.6720 0.0240 2.4300 0.0250 2.3750 0.0260 2.2340 0.0210 2.6480 0.0100 4.6150 0.0100 4.3760 0.0110 4.3820 0.0090 4.7320 0.0270 2.1300 0.0280 2.2640 0.0250 2.2280 0.0250 2.0460 NaN 1.9780 0.0190 2.6340 0.0160 3.4390 0.0170 3.3290 0.0190 3.3020 0.0180 3.2880 0.0140 4.2090 0.0140 4.4640 0.0140 4.1540 0.0140 4.0960 0.0120 4.9550 0.0130 4.7460 0.0130 5.1400 0.0180 2.9620 0.0220 2.4080 0.0190 3.2820 0.0180 3.1390 0.0230 2.2200 0.0280 2.1230 0.0300 2.0740 0.0300 2.0650 0.0310 1.7730 0.0350 1.6130 0.0270 1.8340 0.0260 1.9550 0.0240 2.2780 0.0250 2.1260 0.0230 2.2540 0.0200 2.4080 0.0210 2.2260 0.0130 4.2740 0.0140 4.3850 0.0150 4.1350 0.0140 4.1290 0.0170 3.6720 0.0110 4.6330 0.0130 4.5020 0.0120 4.4560 0.0130 4.4220 0.0190 2.3300 0.0150 3.8920 0.0130 4.0980 0.0130 4.2940 0.0140 4.0770 0.0180 2.9330 0.0220 2.5110 0.0210 2.9790 0.0260 2.1890 0.0220 2.3950 0.0280 2.2880 0.0230 2.5060 0.0280 2.1640 0.0270 2.1000 0.0130 4.1000 0.0140 3.6720 0.0130 3.9880 0.0140 4.0420 0.0150 3.7770 0.0120 4.9520 0.0130 4.4640 0.0130 4.3630 0.0140 4.2370 0.0130 4.7350 0.0120 4.9510 0.0130 3.8210 0.0180 3.1210 0.0160 3.2780 0.0180 2.9450 0.0180 3.0210 0.0230 2.9040 0.0260 1.9500 0.0110 4.9970 0.0120 4.9060 0.0130 4.6540 0.0120 4.4990 0.0180 2.7890 0.0200 2.2790 0.0210 2.4010 0.0220 2.3790 0.0180 2.1240 0.0190 2.3100 0.0210 2.4720 0.0260 2.2650 0.0150 4.0820 0.0160 4.2780 0.0290 1.8670 0.0240 2.1580 0.0200 2.5820 0.0190 2.8680 0.0150 3.3990 0.0240 2.6600 0.0200 2.8070 0.0110 3.6640 0.0200 3.1020 0.0210 2.8750 0.0190 2.9010 0.0150 3.3360 0.0310 1.9500 0.0260 2.4510 0.0320 1.8360 0.0250 2.5420 0.0160 3.7810 0.0160 3.6320 0.0180 3.6130 0.0160 4.1410 0.0130 4.6990 0.0140 4.4570 0.0140 4.6380 0.0140 4.2570 0.0290 2.2190 0.0260 1.9630 0.0260 2.3000 0.0310 1.6490 0.0320 2.0030 0.0280 2.1250 0.0240 2.1080 0.0260 2.2460 0.0240 2.4890 0.0260 2.3910 0.0310 2.0000 0.0190 3.2640 0.0180 3.4590 0.0150 3.4320 0.0150 3.1580 0.0160 4.6680 0.0150 4.4400 0.0160 4.4980 0.0140 4.6570 0.0170 3.9070 0.0160 3.8970 0.0150 3.7300 0.0180 3.7850 0.0210 3.0390 0.0200 3.2210 0.0130 3.1690 0.0290 2.1710 0.0230 2.6390 0.0200 2.9140 0.0230 2.5920 0.0240 2.7020 0.0250 2.2230 0.0240 2.5450 0.0180 2.9840 0.0290 1.9370 0.0190 3.2110 0.0230 2.6940 0.0230 2.9570 0.0220 2.9450 0.0250 2.6710 0.0330 1.7950 0.0280 2.4640 0.0250 2.2200 0.0250 2.5720 0.0260 2.2550 0.0270 2.2020 0.0175 4.2150 0.0160 4.1900 0.0155 3.9620 0.0145 4.2150 0.0220 3.2330 0.0220 3.3530 0.0240 3.0120 0.0225 3.0850 0.0290 2.0350 0.0245 2.1640 0.0290 1.9370 0.0330 1.7950 0.0200 3.6510 0.0180 3.5740 0.0185 3.6450 0.0175 3.1930 0.0295 1.8250 0.0320 1.9900 0.0280 2.1550 0.0265 2.5650 0.0200 3.1500 0.0130 3.9400 0.0190 3.2700 0.0190 2.9300 0.0165 3.8200 0.0165 4.3800 0.0130 4.0550 0.0130 3.8700 0.0130 3.7550 0.0315 2.0450 0.0300 2.1550 0.0360 1.8250 0.0255 2.3000 0.0335 1.9450 0.0175 3.8800 0.0170 4.0600 0.0155 4.1400 0.0150 4.2950 0.0175 3.5200 0.0205 3.4250 0.0190 3.6300 0.0185 3.5250 0.0160 4.2200 0.0155 4.1650 0.0155 4.3250 0.0160 4.3350 0.0290 1.9400 0.0245 2.7400 0.0260 2.2650 0.0255 2.7550 0.0305 2.0510 0.0335 2.0750 0.0300 1.9850 0.0305 2.1900 0.0220 2.8150 0.0215 2.6000 0.0215 2.7200 0.0431 1.9850 0.0361 1.8000 0.0328 1.9850 0.0394 2.0700 0.0361 1.8000 0.0199 3.3650 0.0194 3.7350 0.0202 3.5700 0.0192 3.5350 0.0205 3.1550 0.0202 2.9650 0.0251 2.7200 0.0205 3.4300 0.0194 3.2100 0.0206 3.3800 0.0208 3.0700 0.0186 3.6200 0.0181 3.4100 0.0192 3.4250 0.0177 3.4450 0.0181 3.2050 0.0175 4.0800 0.0300 2.1550 0.0275 2.5600 0.0272 2.3000 0.0309 2.2300 0.0211 2.5150 0.0232 2.7450 0.0238 2.8550 0.0239 2.4050 0.0203 2.8300 0.0170 3.1400 0.0216 2.7950 0.0162 3.4100 0.0315 1.9900 0.0295 2.1350 0.0215 3.2450 0.0198 2.9900 0.0223 2.8900 0.0202 3.2650 0.0206 3.3600 0.0170 3.8400 0.0176 3.7250 0.0165 3.9550 0.0182 3.8300 0.0169 4.3600 0.0155 4.0540 0.0192 3.6050 0.0185 3.9400 0.0319 1.9250 0.0341 1.9750 0.0357 1.9150 0.0274 2.6700 0.0254 3.5300 0.0230 3.9000 0.0272 3.1900 0.0239 3.4200 0.0342 2.2000 0.0345 2.1500 0.0318 2.0200 0.0373 2.1300 0.0284 2.6700 0.0288 2.5950 0.0268 2.7000 0.0335 2.5560 0.0415 2.1440 0.0381 1.9680 0.0321 2.1200 0.0372 2.0190 0.0280 2.6780 0.0264 2.8700 0.0243 3.0030 0.0191 3.3810 0.0343 2.1880 0.0298 2.7110 0.0313 2.5420 0.0370 2.4340 0.0322 2.2650 0.0466 2.1100 0.0279 2.8000 0.0408 2.1100 0.0443 2.0850 0.0434 2.3350 0.0364 2.9500 0.0300 3.2500 0.0446 1.8500 0.0409 1.8350 0.0338 2.1450 0.0298 1.8450 0.0327 2.9100 0.0237 2.4200 0.0350 2.5000 0.0236 2.9050 0.0324 2.2900 0.0272 2.4900 0.0266 2.6350 0.0258 2.6200 0.0235 2.7250 0.0300 2.3850 0.0391 1.7550 0.0390 1.8750 0.0351 1.7600 0.0323 2.0650 0.0370 1.9750 0.0377 2.0500 0.0341 1.9850 0.0347 2.2150 0.0344 2.0450 0.0299 2.3800 0.0330 2.1900 0.0345 2.3200 0.0337 2.2100 0.0324 2.3500 0.0329 2.6150 0.0316 2.6350 0.0281 3.2300 NaN 2.8000 0.0307 3.1600 0.0254 2.9000 0.0242 2.9300 0.0224 3.4150 0.0266 3.7250 0.0202 3.0600 0.0176 3.4650 0.0280 2.6050 0.0270 2.6400 0.0340 2.3950 0.0310 2.5750 0.0290 2.5250 0.0270 2.7350 0.0240 2.8650 0.0230 3.0350 0.0360 1.9800 0.0370 2.0250 0.0310 1.9700 0.0380 2.1250 0.0360 2.1250 0.0360 2.1600 0.0360 2.2050 0.0340 2.2450 0.0380 1.9650 0.0320 1.9650 0.0380 1.9950 0.0250 2.9450 0.0380 3.0150 0.0260 2.5850 0.0220 2.8350 0.0320 2.6650 0.0360 2.3700 0.0270 2.9500 0.0270 2.7900 0.0440 2.1300 0.0320 2.2950 0.0280 2.6250 0.0310 2.7200 mpg = 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 cars = 1.0e+03 * 0.0180 3.5040 0.0150 3.6930 0.0180 3.4360 0.0160 3.4330 0.0170 3.4490 0.0150 4.3410 0.0140 4.3540 0.0140 4.3120 0.0140 4.4250 0.0150 3.8500 NaN 3.0900 NaN 4.1420 NaN 4.0340 NaN 4.1660 NaN 3.8500 0.0150 3.5630 0.0140 3.6090 NaN 3.3530 0.0150 3.7610 0.0140 3.0860 0.0240 2.3720 0.0220 2.8330 0.0180 2.7740 0.0210 2.5870 0.0270 2.1300 0.0260 1.8350 0.0250 2.6720 0.0240 2.4300 0.0250 2.3750 0.0260 2.2340 0.0210 2.6480 0.0100 4.6150 0.0100 4.3760 0.0110 4.3820 0.0090 4.7320 0.0280 2.4640 0.0250 2.2200 0.0250 2.5720 0.0260 2.2550 0.0270 2.2020 0.0175 4.2150 0.0160 4.1900 0.0155 3.9620 0.0145 4.2150 0.0220 3.2330 0.0220 3.3530 0.0240 3.0120 0.0225 3.0850 0.0290 2.0350 0.0245 2.1640 0.0290 1.9370 0.0330 1.7950 0.0200 3.6510 0.0180 3.5740 0.0185 3.6450 0.0175 3.1930 0.0295 1.8250 0.0320 1.9900 0.0280 2.1550 0.0265 2.5650 0.0200 3.1500 0.0130 3.9400 0.0190 3.2700 0.0190 2.9300 0.0165 3.8200 0.0165 4.3800 0.0130 4.0550 0.0130 3.8700 0.0130 3.7550 0.0280 2.6050 0.0270 2.6400 0.0340 2.3950 0.0310 2.5750 0.0290 2.5250 0.0270 2.7350 0.0240 2.8650 0.0230 3.0350 0.0360 1.9800 0.0370 2.0250 0.0310 1.9700 0.0380 2.1250 0.0360 2.1250 0.0360 2.1600 0.0360 2.2050 0.0340 2.2450 0.0380 1.9650 0.0320 1.9650 0.0380 1.9950 0.0250 2.9450 0.0380 3.0150 0.0260 2.5850 0.0220 2.8350 0.0320 2.6650 0.0360 2.3700 0.0270 2.9500 0.0270 2.7900 0.0440 2.1300 0.0320 2.2950 0.0280 2.6250 0.0310 2.7200 mpg = 33.0000 29.5000 26.0000 29.0000 38.0000 32.0000