Skip to content

Instantly share code, notes, and snippets.

@svalleru
Created June 15, 2016 23:53
Show Gist options
  • Save svalleru/70f0a1e5eccf928c4902902bd24c371d to your computer and use it in GitHub Desktop.
Save svalleru/70f0a1e5eccf928c4902902bd24c371d to your computer and use it in GitHub Desktop.
Calculate lowest possible denominations for given change
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