Assignment title: Information


C. Write a function even_fruit/1, which takes as argument a list of pairs each consisting of an atom and a positive integer, and returns a list of atoms. The function's input represents different kinds of fruit and their quantities (numbers). The function's output should be a list of atoms representing fruit, with an atom for each fruit that has an even quantity in the input list. Fruit appearing many times in the input list should be treated as separate. You should use your even_odd/1 function from assignment 1. Ex: even_fruit([{orange, 3}, {apple, 2}, {banana, 4}, {orange, 2}, {leechee, 5}, {apple, 6}]) → [apple, banana, orange, apple] D. You are operating a small ferry that can carry two vehicles. There is a number of vehicles to be transported. However, due to weight restrictions not all pairs may be transported together. Write a function ferry_vehicles/2, which takes as arguments an integer N and a list of pairs of the form {Vehicle, Weight}, where Vehicle describes the kind of the vehicle and Weight is a positive integer describing its weight. The vehicle descriptions in the list are all unique. The function's output should be a list of triples {Vehicle1, Vehicle2, M}, where Vehicle1 and Vehicle2 are vehicle descriptions from the input for two (different) vehicles, and M is their combined weight, which must be most N. All valid pairs of vehicles should be present in the output twice (also as {Vehicle2, Vehicle1, M}). Ex: ferry_vehicles(3200, [{compact, 1500}, {crossover, 1900}, {mini, 1200}, {keicar, 800}, {minibus, 2200}]) → [{compact,mini,2700}, {compact,keicar,2300}, {crossover,mini,3100}, {crossover,keicar,2700}, {mini,compact, 2700}, {mini,crossover,3100}, {mini,keicar,2000}, {keicar,compact,2300}, {keicar,crossover,2700}, {keicar,mini, 2000}, {keicar,minibus,3000}, {minibus,keicar,3000}] (This is only one of possible results) E. Write a function ferry_vehicles2/2, which takes the samearguments as ferry_vehicles/2, but returns a list of valid vehicle pairs (together with combined weights) without duplicate pairs. Ex: ferry_vehicles(3200, [{compact, 1500}, {crossover, 1900}, {mini, 1200}, {keicar, 800}, {minibus, 2200}]) → [{mini,compact,2700}, {mini,crossover,3100}, {mini,keicar, 2000}, {keicar,compact,2300}, {keicar,crossover,2700}, {minibus,keicar,3000}] (This is only one of possible results)