Created
June 15, 2016 23:53
-
-
Save svalleru/70f0a1e5eccf928c4902902bd24c371d to your computer and use it in GitHub Desktop.
Calculate lowest possible denominations for given change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
denominations = [25, 10, 1, 100] | |
change = 66 | |
for d in sorted(denominations, reverse=True): | |
q, r = divmod(change, d) | |
print d, '*', q | |
change = r | |
# 100 * 0 | |
# 25 * 2 | |
# 10 * 1 | |
# 1 * 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment