While cooking your favorite recipe, you realize that you have put the wrong quantity of one or more of the ingredients into your mixing bowl. You must figure out the minimum amount of each ingredient that must be added to the bowl to fix your mistake. It is essential to end up with at least the quantities required in the recipe and to maintain the ingredient proportions.
For instance, if you used 2 cups of flour in a recipe that requires 3 cups, all you have to do is add 1 more cup. If, in another recipe, you used 2 teaspoons of salt where only 1 teaspoon was required, you must make sure that all of the recipe's ingredients are doubled to maintain the correct proportions.
You are able to measure quantities in teaspoons (tsp), tablespoons (Tbsp), and cups. A teaspoon is the smallest amount that can be added to the bowl. 3 teaspoons are equivalent to 1 tablespoon. 16 tablespoons are equivalent to 1 cup.
You will be given a String[] recipe that lists the required ingredients, and a String[] mixingBowl listing the ingredients that are in the bowl. Your program should return a String[] indicating the quantities of only the ingredients that must be added. The ingredients should be in the same order that they appear in recipe. If no ingredients need to be added, then the result should have 0 elements.
Each element of the result must indicate the maximum number of cups to be added, followed by the the maximum number of tablespoons, and finally the remaining teaspoons to be added. In general, each element should be formatted (quotes for clarity) as "QTY cups QTY Tbsp QTY tsp NAME", where each QTY is an integer with no leading zeros, and NAME is the name of the ingredient. If none of a certain unit needs to be added, then that unit should be excluded from the element.
|