If we're using other denominations, this algorithm could run into trouble. I believe it would only occur when one bill is more than 50% of the value of the bill above it.

As an example, if there was a $3 bill, then $9 would be best served by 3x$3, while this algorithm would give 1x$5 + 4x$1.

I think you are still OK as the algorithm should in that case use 1x$5 + 1x$3 + 1x$1.

Paul

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to