Python Forum

Full Version: List Code
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Dear all, I am lerning Python and would like to know if it is possible to implement the following:

Lets suppose I'm a fruit distribuitor and I have in my stock: 3 bananas, 3 apples, 3 oranges.

And I have 3 markets with the current stock:

Market A: 1 orange / 2 apples / 3 banana
Market B: 2 oranges / 5 apples / 1 banana
Market C: 5 oranges / 1 apple / 2 banana

How would I program that python retrieve me the best market to fit each fruit and the ideal volume of it... based on the current stock and my distribuitor volume?

The answer for this would be:

Market A: receive: 2 oranges / 1 apple / 0 banana
Market B: receive: 1 oranges / 0 apple / 2 banana
Market C: receive: 0 oranges / 2 apple / 1 banana

However lts suppose that I have thousands of markets and many other thousands of fruits... Is this really possible?

Appreciate all support!!!

Greetings! Big Grin Big Grin
Looks like a homework assignment.

Please show what you have tried so far.
We are glad to help, but expect you to make a good effort as well.
If you've already written some code, show what you've got, and where there is an issue.