Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 4 : Flower Bunches This is a more challenging problem that will require you to take your time and design a solution. We have

Part 4: Flower Bunches
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 ([])
outputs:
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

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

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions

Question

How effective have these groups been in the past?

Answered: 1 week ago

Question

What are their reputations?

Answered: 1 week ago

Question

How serious a response is warranted to this situation?

Answered: 1 week ago