You live in a remote settlement where bread sellers come through periodically at irregular
intervals. Whenever you buy fresh bread, it lasts for 30 days until it becomes too stale to eat.
Your family eats one loaf of bread per day.
You are given a calendar of when the bread sellers will be visiting over the coming days and the
price each bread seller will charge per loaf. You currently have 10 fresh loaves, and at the end
of the calendar you'll get a bunch of free bread, so you won't need to have any left on hand.
Write a function that tells you how much bread to buy from each of the sellers
total_days, an integer, the number of days in the calendar until the free bread arrives
sellers, a list of pairs of integers (day, price). Each pair represents one bread seller
The day is how many days from the start until the seller arrives
The price is the price to buy each loaf of bread from this seller, in pennies
purchases, a list of integers of the same length as sellers. Each integer is how many
loaves you should buy from each seller
Or None, if there is no solution that does not force your family to eat stale bread at some point
You should output the purchase plan that minimizes the total cost. In case of ties, output the
plan that requires buying from the fewest number of different sellers, and within those choose
the plan that buys more bread earlier
Please write a well formatted, easily readable python function
calculate_purchasing_plan(total_days, sellers) in a file called
[login to view URL] that solves this problem using only the standard python (i.e. no packages
Please include a comment at the top of the file with your name and email as well as a short
paragraph describing why the algorithm you’ve provided should work.
>>> calculate_purchasing_plan(60, [(10,200), (15,100), (35,500), (50,30)])
[5, 30, 5, 10]
21 pekerja bebas membida secara purata £104 untuk pekerjaan ini
HI. As a python expert with strong math background, I can finish your project perfectly, I think. Please let me know your detailed requirements. Thanks.
Hi, I'm a software developer with over 5 years of experience working on java, python and many other tools and technologies. I have solved algorithmic problems before and can do this job efficiently. thanks, tousif
Python expert, Algorithms developer at MTEQ, AI / Machine learning engineer. Regularly receive complements on my excellent python code uwu [login to view URL], [login to view URL]
Hi I gone through problem statement very carefully and have an idea to develop an algorithm for it. Please message me to discuss more about problem, budget and deadlines.