Given a total of x oranges, and y mangoes, how do you share the y mangoes among w number of farmers based on the number of oranges each farmer owns.
That is, If there are 5 oranges and 10 mangoes, then for every orange presented, the farmer gets 10/5 mangoes(2 mangoes).
The minimum number of oranges a farmer can have to have a share in the mango is z.
When a farmer comes to claim his/her share of the y mangoes, he/she must have at least z number of oranges. Else, his/her share is added to that of the other farmers.
That is, if the minimum is 4 oranges, and you have only 2, you get no mango and your loss(4 mangoes) is distributed to the other farmers that have the minimum number of oranges.
What simple and computational feasible formular can we use to easily compute each farmer's share as they present their oranges to claim mangoes?
Please sorry about the formatting. I'm new here. Thanks.
My incomplete/unsure solution:
Step 1: Multiply the number of farmers(w) by the minimum oranges required to get a share(z). Let's call the result MINS.
Step 2: Subtract the MINS from the total oranges(x). Let's call that REQ.
Step 3: When a farmer presents U oranges to claim mangoes. use f to compute the farmer's portion of the mangoes.
f = ((U - z) / REQ) * y
That's my solution so far. But it's not correct right?