Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python Please If You Need More Reference Check Out : https://www.chegg.com/homework-help/questions-and-answers/python-please-would-mean-lot-q44357347 - Problem 3: Checking simultaneous recipe feasibility Similar to the previous problem, we

In Python Please

If You Need More Reference Check Out : https://www.chegg.com/homework-help/questions-and-answers/python-please-would-mean-lot-q44357347

image text in transcribed

image text in transcribed

- Problem 3: Checking simultaneous recipe feasibility Similar to the previous problem, we want to know recipes we can make given the current contents of our pantry, but this time, for multiple recipes at once. For this problem, you will implement a simul_feasible_nr method for the Pantry class. This method takes a list of recipes and returns a list containing all of the different combinations of recipes that could be simultaneously made using the available ingredients in the pantry, without repeating any recipe in each combination. (The "nr" in the name stands for "non-repeating".) simul_feasible_nr should return a list of lists. That is, the returned value should be a list, where each element in that list is itself a list representing a particular combination of recipes. Neither the order of the outer list nor the order of the inner list matters. A combination of recipes has a minimum of 1 recipe and has no maximum size, as long as the pantry has enough ingredients. Hints: simul_feasible_nr may call the individually_feasible method defined above. You may find it useful to define an inner function that calls itself recursively. [ ] def simul_feasible_nr(self, recipes): "" "Returns a list containing different combinations of recipes that could be made simultaneously using the ingredients available in the pantry."" # YOUR CODE HERE raise NotImplementedError(). Pantry.simul_feasible_nr = simul_feasible_nr If simul_feasible_nr is working correctly, then the below cell should print something like this: Recipe(s) that can be made simultaneously: * Fried Rice Recipe(s) that can be made simultaneously: * Fried Rice * Spinach-Mushroom Scrambled Eggs Recipe(s) that can be made simultaneously: * Rice and Beans Recipe(s) that can be made simultaneously: * Rice and Beans * Spinach-Mushroom Scrambled Eggs Recipe(s) that can be made simultaneously: * Spinach-Mushroom Scrambled Eggs [] pl = Pantry({ "egg":6, "beans":11, "rice":7, "onion": 1, "mushrooms":1, "spinach":1, "cheese":1, "soy sauce":1, "butter":1, "oil":2}) fried rice = Recipe ("Fried Rice", {"rice":4, "egg":2, "onion":1, "soy sauce":1, "oil":1}) rice_and_beans = Recipe ("Rice and Beans", {"rice":4, "beans":4, "oil":1}) spinach_mushroom_scrambled_eggs = Recipe ("Spinach-Mushroom Scrambled Eggs", {"egg":4, "mushrooms":1, "spinach":0.2, "cheese":1, "butter":1}) watermelon = Recipe ("Watermelon", {"watermelon":1}) pl_simul_feasible_nr = pl.simul_feasible_nr([fried_rice, rice_and_beans, spinach_mushroom_scrambled_eggs, watermelon]) for collection in pl_simul_feasible_nr: print("Recipe(s) that can be made simultaneously:") for recipe in collection: print(" * {}".format(recipe.name)) print("") - Problem 3: Checking simultaneous recipe feasibility Similar to the previous problem, we want to know recipes we can make given the current contents of our pantry, but this time, for multiple recipes at once. For this problem, you will implement a simul_feasible_nr method for the Pantry class. This method takes a list of recipes and returns a list containing all of the different combinations of recipes that could be simultaneously made using the available ingredients in the pantry, without repeating any recipe in each combination. (The "nr" in the name stands for "non-repeating".) simul_feasible_nr should return a list of lists. That is, the returned value should be a list, where each element in that list is itself a list representing a particular combination of recipes. Neither the order of the outer list nor the order of the inner list matters. A combination of recipes has a minimum of 1 recipe and has no maximum size, as long as the pantry has enough ingredients. Hints: simul_feasible_nr may call the individually_feasible method defined above. You may find it useful to define an inner function that calls itself recursively. [ ] def simul_feasible_nr(self, recipes): "" "Returns a list containing different combinations of recipes that could be made simultaneously using the ingredients available in the pantry."" # YOUR CODE HERE raise NotImplementedError(). Pantry.simul_feasible_nr = simul_feasible_nr If simul_feasible_nr is working correctly, then the below cell should print something like this: Recipe(s) that can be made simultaneously: * Fried Rice Recipe(s) that can be made simultaneously: * Fried Rice * Spinach-Mushroom Scrambled Eggs Recipe(s) that can be made simultaneously: * Rice and Beans Recipe(s) that can be made simultaneously: * Rice and Beans * Spinach-Mushroom Scrambled Eggs Recipe(s) that can be made simultaneously: * Spinach-Mushroom Scrambled Eggs [] pl = Pantry({ "egg":6, "beans":11, "rice":7, "onion": 1, "mushrooms":1, "spinach":1, "cheese":1, "soy sauce":1, "butter":1, "oil":2}) fried rice = Recipe ("Fried Rice", {"rice":4, "egg":2, "onion":1, "soy sauce":1, "oil":1}) rice_and_beans = Recipe ("Rice and Beans", {"rice":4, "beans":4, "oil":1}) spinach_mushroom_scrambled_eggs = Recipe ("Spinach-Mushroom Scrambled Eggs", {"egg":4, "mushrooms":1, "spinach":0.2, "cheese":1, "butter":1}) watermelon = Recipe ("Watermelon", {"watermelon":1}) pl_simul_feasible_nr = pl.simul_feasible_nr([fried_rice, rice_and_beans, spinach_mushroom_scrambled_eggs, watermelon]) for collection in pl_simul_feasible_nr: print("Recipe(s) that can be made simultaneously:") for recipe in collection: print(" * {}".format(recipe.name)) print("")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions

Question

Find dy/dx if x = te, y = 2t2 +1

Answered: 1 week ago