I'm sure I can't be the only one who still sometimes pays for things with cash, and chooses the amount of cash I give in a way that will cause the change to be a round number. But there can't be very many of us, because every time I do I totally bewilder the cashier I'm dealing with. It doesn't help that they're very seldom capable of making change in their heads.
Today's example: my lunch bill was $10.67. I knew that I had not very many coins, but I had more $1 bills than I wanted, and didn't have any $5 or $10 bills. So, I handed over $21. This confused the cashier so badly that she rang it up as if I had given her $11, realized her mistake, asked me if I knew that I had given her $21, and was unable to figure out what to give me in change (even with the difference between $11 and $10.67 visible on the register screen) without totally redoing the whole transaction from scratch.
But this led me to think about the following variations on the classical change-making problem
. They might make good dynamic programming exercises, in part because it's less obvious how to use a greedy algorithm to solve them than it is to use a greedy algorithm for change-making.Simplest change
: given a payment amount, a set of coins (or bills) that can be used for the payment, and a (possibly different) set of coins/bills that can be used to make change, choose how much to pay in order to minimize the number of coins/bills you will get back in change.Simplest transaction
: with the same input data, choose how much to pay in order to minimize the total number of coins/bills that change hands in both directions. (Previously
: with the same input data, choose how much to pay in order to minimize the total number of coins/bills that you end up with after the transaction, including both your change and the coins and bills that you didn't use to pay the charge.
In all cases, let's assume that the cashier either knows how to give you the optimal change or can be guided by the register into doing so. I'd add another problem here, about choosing how to pay in order to minimize the transaction time and least annoy the math-phobic cashiers, but I'm sure using a credit card or debit card is the answer for that.