4
On a road trip, N people pay for fuel. Each pays a different amount. At the end of the trip, calculate the minimum number of transactions so that each person has paid the same amount.
e.g. on the road trip, these people pay for fuel
- Dave - $50
- John - $25
- George - $5
- Barry - $0
After the road trip:
- Barry pays Dave $20
- George pays John $5
- George pays Dave $10
Added: The output of the program should list the transactions.
Bonus points if the solution is written in Visual Basic.
3Why the Visual Basic bonus? – Hasturkun – 2012-09-06T17:23:43.977
@Hasturkun - Because I'd like to try this on an Excel spreadsheet. – Rocketmagnet – 2012-09-06T17:44:40.433
1id recommend having an exact win condition; before the heavy-handed moderators swing on by :) – NRGdallas – 2012-10-24T17:07:58.297
you need to specify a winning condition for the question in order for it to be on-topic – proud haskeller – 2014-09-15T15:19:11.393