Question: This is a more challenging problem that will require you to take your time and design a solution. We have a scenario where we have

This is a more challenging problem that will require you to take your time and design a solution. We have a scenario where we have high value flowers, low value flowers, and greenery (the decorative leaves and accessories. Given a budget, we want to spend our entire budget to create a bunch of flowers. Write a function make_bunch(high, low, green, budget) takes integer for number of high, low and greenery items, and a budget, and returns a list of the flowers used to make the bunch.
There are a number of rules
High value flowers which cost 4 each, and a maximum of 4 can be used, regardless of how many flowers are available.
Low value flowers cost 2 each, and any number can be used
Greenery costs 0.50 each, and a bunch needs a minimum of 4 items of greenery, with no
maximum
The entire budget must be used.
If a bunch cannot be created within the rules and there is budget left over, then return an
empty list ([])
If a bunch cannot be created due a a lack of flowers, return an empty list ([])make_bunch(4,8,10,15)->[3,0,6]
Here, we input 4 high values, 8 low values, 10 greenery, and a budget of 15. The resulting output is 3 high value flowers (12),0 low values flowers, and 6 greenery items (3)
make_bunch(3,8,10,19)->[3,2,6]
Outputs 3 large flowers (12),2 low value flowers (4), and 6 pieces of greenery (3)
make_bunch(4,8,2,15)->[]
Here, there is not enough greenery to satisfy the minimum rules, and so an empty list is returned.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!