Let's say we have N number of accounts with positive balances B_1, ..., B_n .
We can make a transfer T(from,to,amount) , which moves a certain amount of balance between accounts.
We have knowledge about the optimal distribution of residues O_1, ..., O_n .
The question arises: how can we find a minimal set of gears that achieve optimal distribution? Can we always avoid passing N-1 no more?
Example:
Balances {0}: 10, {1}: 40, {2}: 50 Optimal {0}: 20, {1}: 60, {2}: 20 T(2,0,10) => {0}: 20, {1}: 40, {2}: 40 T(2,1,20) => {0}: 20, {1}: 60, {2}: 20
algorithm
randomguy
source share