I am new here. I usually stick to programming forums but my problem here is mathematical in nature and I just need a few pointers before I can go out and code a solution. By the looks of the forum, I wish I had come here when I was still at university... Anyway, the problem is below (somewhat simplified):
There are a large number of people that require a certain amount of apples. They can only trade apples with each other, and I want to figure out the quickest way (least number of trades) required for each to finish with the number of apples that they need. For example, for people named A-F:
B gives A 250
D gives B 100
F gives C 300
F gives B 20
F gives E 20
Now if there was 50 people, or even 1000 people, this may get quite complicated. How would one go about finding the smallest number of trades possible to get the required result (and the size / direction of the trades)?
Thanks in advance for any ideas on where to start!