Name: Anonymous 2010-01-08 0:52
Any number of people each with their own
specific number of gold coins.
I need to distribute some random number of
gold coins to these people in the most even
fashion starting with the poorest.
One way to do this would be to sort an array
assuming 2 element {(person, gold),...} by the
gold (array = dictionary in python) give a coin
to the first element (assume sort from low to
high), and repeat this until all coins have
been given out.
It seems stupid to sort each time I give a coin.
Help me with a more efficient way?
Please in python or pseudocode or english.
specific number of gold coins.
I need to distribute some random number of
gold coins to these people in the most even
fashion starting with the poorest.
One way to do this would be to sort an array
assuming 2 element {(person, gold),...} by the
gold (array = dictionary in python) give a coin
to the first element (assume sort from low to
high), and repeat this until all coins have
been given out.
It seems stupid to sort each time I give a coin.
Help me with a more efficient way?
Please in python or pseudocode or english.