""" Itemlist is a list of tuples (itemID,itemCost) of items that we need to buy from our supplier. Write a function that takes itemlist and returns a list with the smallest number of supplier orders needed to buy all the items knowing that each order has a maximum purchase value given by maxp. For each order the total cost and its item composition must be returned by the function. Extra question: how would you modify the function if there were also a minimum purchase per order, minp ? """ itemlist = [(9441, 84.71), (9590, 16.95), (9595, 43.57), (9596, 24.20), (9600, 108.91), (9604, 58.09), (9605, 33.89), (9632, 33.89), (9639, 62.93), (9645, 133.89), (9646, 23.89), (9649, 87.93), (9683, 19.33),] maxp = 240 print maxp print itemlist
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question