Cody

Problem 44952. Find MPG of Lightest Cars

Solution 3867468

Submitted on 26 Nov 2020
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   Fail
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 = 406x5 table <strong>Model</strong> <strong>MPG</strong> <strong>Horsepower</strong> <strong>Weight</strong> <strong>Acceleration</strong> <strong>______________________________________</strong> <strong>____</strong> <strong>__________</strong> <strong>______</strong> <strong>____________</strong> "ih 1200d" 9 193 4732 18.5 "ford f250" 10 215 4615 14 "chevrolet c20" 10 200 4376 15 "dodge d200" 11 210 4382 13.5 "mercury marquis" 11 208 4633 11 "chevrolet impala" 11 150 4997 14 "oldsmobile omega" 11 180 3664 11 "dodge monaco (sw)" 12 180 4955 11.5 "oldsmobile delta 88 royale" 12 160 4456 13.5 "mercury marquis brougham" 12 198 4952 11.5 "buick electra 225 custom" 12 225 4951 11 "ford country" 12 167 4906 12.5 "oldsmobile vista cruiser" 12 180 4499 12.5 "ford country squire (sw)" 13 170 4746 12 "pontiac safari (sw)" 13 175 5140 12 "chevrolet impala" 13 165 4274 12 "buick lesabre custom" 13 155 4502 13.5 "chrysler newport royal" 13 190 4422 12.5 "chevrolet chevelle concours (sw)" 13 130 4098 14 "ford gran torino (sw)" 13 140 4294 16 "buick century 350" 13 175 4100 13 "chevrolet malibu" 13 145 3988 13 "chevrolet caprice classic" 13 150 4464 12 "ford ltd" 13 158 4363 13 "chrysler new yorker brougham" 13 215 4735 11 "amc ambassador brougham" 13 175 3821 11 "plymouth custom suburb" 13 170 4654 13 "buick century luxus (sw)" 13 150 4699 14.5 "ford mustang ii" 13 129 3169 12 "plymouth volare premier v8" 13 150 3940 13.2 "chevrolet c10" 13 145 4055 12 "ford f108" 13 130 3870 15 "dodge d100" 13 150 3755 14 "chevrolet impala" 14 220 4354 9 "plymouth fury iii" 14 215 4312 8.5 "pontiac catalina" 14 225 4425 10 "plymouth 'cuda 340" 14 160 3609 8 "buick estate wagon (sw)" 14 225 3086 10 "chevrolet impala" 14 165 4209 12 "pontiac catalina brougham" 14 175 4464 11.5 "ford galaxie 500" 14 153 4154 13.5 "plymouth fury iii" 14 150 4096 13 "pontiac catalina" 14 175 4385 12 "ford galaxie 500" 14 153 4129 13 "plymouth satellite custom (sw)" 14 150 4077 14 "amc matador" 14 150 3672 11.5 "ford gran torino" 14 137 4042 14.5 "plymouth fury gran sedan" 14 150 4237 14.5 "dodge coronet custom (sw)" 14 150 4457 13.5 "ford gran torino (sw)" 14 140 4638 16 "amc matador (sw)" 14 150 4257 15.5 "ford ltd" 14 148 4657 13.5 "ford gran torino" 14.5 152 4215 12.8 "buick skylark 320" 15 165 3693 11.5 "ford galaxie 500" 15 198 4341 10 "amc ambassador dpl" 15 190 3850 8.5 "dodge challenger se" 15 170 3563 10 "chevrolet monte carlo" 15 150 3761 9.5 "plymouth fury iii" 15 150 4135 13.5 "amc matador (sw)" 15 150 3892 12.5 "dodge coronet custom" 15 150 3777 12.5 "chevrolet monte carlo s" 15 145 4082 13 "dodge dart custom" 15 150 3399 11 "chevrolet nova" 15 100 3336 17 "mercury monarch" 15 72 3432 21 "ford maverick" 15 72 3158 19.5 "chevrolet bel air" 15 145 4440 14 "amc matador" 15 110 3730 19 "mercury cougar brougham" 15 130 4295 14.9 "amc matador" 15.5 120 3962 13.9 "dodge monaco brougham" 15.5 145 4140 13.7 "chevrolet monte carlo landau" 15.5 170 4165 11.4 "chrysler cordoba" 15.5 190 4325 12.2 "ford country squire (sw)" 15.5 142 4054 14.3 "amc rebel sst" 16 150 3433 12 "plymouth satellite custom" 16 105 3439 15.5 "chevrolet nova custom" 16 100 3278 18 "pontiac grand prix" 16 230 4278 9.5 "chevrolet chevelle malibu classic" 16 100 3781 17 "amc matador" 16 110 3632 18 "ford gran torino" 16 140 4141 14 "pontiac catalina" 16 170 4668 11.5 "plymouth grand fury" 16 150 4498 14.5 "chevrolet chevelle malibu" 16 105 3897 18.5 "dodge coronet brougham" 16 150 4190 13 "pontiac grand prix lj" 16 180 4220 11.1 "ford thunderbird" 16 149 4335 14.5 "peugeot 604sl" 16.2 133 3410 15.8 "mercedes-benz 280s" 16.5 120 3820 16.7 "cadillac seville" 16.5 180 4380 12.1 "mercury grand marquis" 16.5 138 3955 13.2 "buick estate wagon (sw)" 16.9 155 4360 14.9 "ford torino" 17 140 3449 10.5 "chevrolet chevelle malibu" 17 100 3329 15.5 "amc ambassador sst" 17 150 3672 11.5 "buick century" 17 110 3907 21 "oldsmobile cutlass supreme" 17 110 4060 19 "volvo 264gl" 17 125 3140 13.6 "chevrolet caprice classic" 17 130 3840 15.4 "chevrolet chevelle malibu classic" 17.5 140 4215 13 "amc pacer d/l" 17.5 95 3193 17.8 "chevrolet caprice classic" 17.5 145 3880 12.5 "chevrolet concours" 17.5 110 3520 16.4 "dodge magnum xe" 17.5 140 4080 13.7 "ford ltd landau" 17.6 129 3725 13.4 "chrysler lebaron salon" 17.6 ...

Assertion failed.

2   Fail
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 = 100x5 table <strong>Model</strong> <strong>MPG</strong> <strong>Horsepower</strong> <strong>Weight</strong> <strong>Acceleration</strong> <strong>___________________________________</strong> <strong>____</strong> <strong>__________</strong> <strong>______</strong> <strong>____________</strong> "ih 1200d" 9 193 4732 18.5 "ford f250" 10 215 4615 14 "chevrolet c20" 10 200 4376 15 "dodge d200" 11 210 4382 13.5 "plymouth volare premier v8" 13 150 3940 13.2 "chevrolet c10" 13 145 4055 12 "ford f108" 13 130 3870 15 "dodge d100" 13 150 3755 14 "chevrolet impala" 14 220 4354 9 "plymouth fury iii" 14 215 4312 8.5 "pontiac catalina" 14 225 4425 10 "plymouth 'cuda 340" 14 160 3609 8 "buick estate wagon (sw)" 14 225 3086 10 "ford gran torino" 14.5 152 4215 12.8 "buick skylark 320" 15 165 3693 11.5 "ford galaxie 500" 15 198 4341 10 "amc ambassador dpl" 15 190 3850 8.5 "dodge challenger se" 15 170 3563 10 "chevrolet monte carlo" 15 150 3761 9.5 "amc matador" 15.5 120 3962 13.9 "amc rebel sst" 16 150 3433 12 "dodge coronet brougham" 16 150 4190 13 "mercedes-benz 280s" 16.5 120 3820 16.7 "cadillac seville" 16.5 180 4380 12.1 "ford torino" 17 140 3449 10.5 "chevrolet chevelle malibu classic" 17.5 140 4215 13 "amc pacer d/l" 17.5 95 3193 17.8 "chevrolet chevelle malibu" 18 130 3504 12 "plymouth satellite" 18 150 3436 11 "amc hornet" 18 97 2774 15.5 "ford granada ghia" 18 78 3574 21 "pontiac ventura sj" 18.5 110 3645 16.2 "peugeot 504" 19 88 3270 21.9 "toyota mark ii" 19 108 2930 15.5 "dodge aspen se" 20 100 3651 17.7 "volvo 245" 20 102 3150 15.7 "ford maverick" 21 85 2587 16 "amc gremlin" 21 90 2648 15 "plymouth duster" 22 95 2833 15.5 "plymouth valiant" 22 100 3233 15.4 "chevrolet nova" 22 105 3353 14.5 "ford granada l" 22 112 2835 14.7 "amc hornet" 22.5 90 3085 17.6 "amc concord dl" 23 NaN 3035 20.5 "toyota corona mark ii" 24 95 2372 15 "audi 100 ls" 24 90 2430 14.5 "ford maverick" 24 81 3012 17.6 "ford fairmont futura" 24 92 2865 16.4 "chevrolet woody" 24.5 60 2164 22.1 "peugeot 504" 25 87 2672 17.5 "saab 99e" 25 95 2375 17.5 "opel 1900" 25 81 2220 16.9 "ford capri ii" 25 92 2572 14.9 "buick century limited" 25 110 2945 16.4 "volkswagen 1131 deluxe sedan" 26 46 1835 20.5 "bmw 2002" 26 113 2234 12.5 "dodge colt" 26 79 2255 17.7 "chrysler lebaron medallion" 26 92 2585 14.5 "ford pinto" 26.5 72 2565 13.6 "datsun pl510" 27 88 2130 14.5 "renault 12tl" 27 83 2202 15.3 "chevrolet cavalier wagon" 27 88 2640 18.6 "pontiac phoenix" 27 90 2735 18 "chevrolet camaro" 27 90 2950 17.3 "ford mustang gl" 27 86 2790 15.6 "fiat 131" 28 86 2464 15.5 "toyota corolla" 28 75 2155 16.4 "chevrolet cavalier" 28 88 2605 19.6 "ford ranger" 28 79 2625 18.6 "chevrolet chevette" 29 52 2035 22.2 "volkswagen rabbit" 29 70 1937 14.2 "dodge aries se" 29 84 2525 16 "volkswagen rabbit" 29.5 71 1825 12.2 "pontiac j2000 se hatchback" 31 85 2575 16.2 "mazda glc custom" 31 68 1970 17.6 "chevrolet s-10" 31 82 2720 19.4 "datsun b-210" 32 70 1990 17 "honda civic (auto)" 32 67 1965 15.7 "toyota celica gt" 32 96 2665 13.9 "dodge rampage" 32 84 2295 11.6 "honda civic" 33 53 1795 17.4 "chevrolet cavalier 2-door" 34 88 2395 18 "toyota corolla" 34 70 2245 16.9 "volkswagen rabbit l" 36 74 1980 15.3 "mercury lynx l" 36 70 2125 17.3 "nissan stanza xe" 36 88 2160 14.5 "honda accord" 36 75 2205 14.5 "dodge charger 2.2" 36 84 2370 13 "mazda glc custom l" 37 68 2025 18.2 "plymouth horizon miser" 38 63 2125 14.7 "honda civic" 38 67 1965 15 "datsun 310 gx" 38 67 1995 16.2 "oldsmobile cutlass ciera (diesel)" 38 85 3015 17 "volkswagen pickup" 44 52 2130 24.6 "citroen ds-21 pallas" NaN 115 3090 17.5 "chevrolet chevelle concours (sw)" NaN 165 4142 11.5 "ford torino (sw)" NaN 153 4034 11 "plymouth satellite (sw)" NaN 175 4166 10.5 "amc rebel sst (sw)" NaN 175 3850 11 "ford mustang boss 302" NaN 140 3353 8

Assertion failed.

Suggested Problems

More from this Author13

Community Treasure Hunt

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

Start Hunting!