Question 20 (Advanced problem) DV DN! DW DW DW DW DW DW D You are a cooking robot who has been given an encoded string o
Posted: Thu May 26, 2022 9:05 am
Question 20 (Advanced problem) DV DN! DW DW DW DW DW DW D You are a cooking robot who has been given an encoded string of ingredients and dish names. You are tasked with reading in this string and determining how many of each dish you can make. The key for the string encoding is below. Ingredients: M = Milk E = Eggs F = Flour S = Sugar Dishes: P = Pancakes D = Danish C = Custard This means that the string MEMMSSFCMMEP means you have 2 dishes to cook. The first is custard, for which you have 3 Milk, 1 Eggs, 2 Sugar, 1 Flour. The second is Pancakes, for which you have 2 Milk and 1 Eggs. For this example, we would be able to make the custard, but not the pancakes. Note: after you have read a character corresponding to a dish, you may only use the ingredients seen since the last dish character (i.e, after each dish, you must clear you ingredients list) The recipes for the dishes are as follows: Pancakes: 2 Eggs, 1 Milk, 1 Flour, 1 sugar Danish: 2 Eggs, 2 Milk, 2 Flour, 2 sugar
The recipes for the dishes are as follows: 070 0÷0 070 070 070 070 070 | Pancakes: 2 Eggs, 1 Milk, 1 Flour, 1 sugar Danish: 2 Eggs, 2 Milk, 2 Flour, 2 sugar Custard: 3 Milk, 1 Eggs You must return the number of complete dishes you can make in a list of the form [#pancake, #danish, #custard, #None], where the number at index 0 is the number of pancakes that can be made, the number at index 1 is the number of danishes that can be made, the number at index 2 is the number of custards that can be made and the number at index 3 is the number of dishes that could not be made with the preceding ingredients. Note: Do not worry about calculating multiple dishes per batch of ingredients, simply determine if a dish can or can not be created70 def get_dishes (cook_string): input: a string of characters representing a list of ingredients separated by a character representing a dish to make output: a list containing the number of each dish that can be made and the total number of dishes that could not be made Examples: >>>get_dishes ("MEMMSSFCMMEP") [0, 0, 1, 1] >>> get_dishes ("MMFFSSEEPMFSEMFSEDSSSC") [1, 1, 0, 1] >>> get_dishes ("EEEMMFSPMMEC") [1, 0, 0, 1] IT 11 TE DI 2 ‒‒‒‒‒‒‒‒‒‒‒‒‒ Atsi
The recipes for the dishes are as follows: 070 0÷0 070 070 070 070 070 | Pancakes: 2 Eggs, 1 Milk, 1 Flour, 1 sugar Danish: 2 Eggs, 2 Milk, 2 Flour, 2 sugar Custard: 3 Milk, 1 Eggs You must return the number of complete dishes you can make in a list of the form [#pancake, #danish, #custard, #None], where the number at index 0 is the number of pancakes that can be made, the number at index 1 is the number of danishes that can be made, the number at index 2 is the number of custards that can be made and the number at index 3 is the number of dishes that could not be made with the preceding ingredients. Note: Do not worry about calculating multiple dishes per batch of ingredients, simply determine if a dish can or can not be created70 def get_dishes (cook_string): input: a string of characters representing a list of ingredients separated by a character representing a dish to make output: a list containing the number of each dish that can be made and the total number of dishes that could not be made Examples: >>>get_dishes ("MEMMSSFCMMEP") [0, 0, 1, 1] >>> get_dishes ("MMFFSSEEPMFSEMFSEDSSSC") [1, 1, 0, 1] >>> get_dishes ("EEEMMFSPMMEC") [1, 0, 0, 1] IT 11 TE DI 2 ‒‒‒‒‒‒‒‒‒‒‒‒‒ Atsi