Skip to content

Instantly share code, notes, and snippets.

@robmoore
Created December 11, 2018 01:04
Show Gist options
  • Save robmoore/78d010c03a8462e8a1ab89bea05938ba to your computer and use it in GitHub Desktop.
Save robmoore/78d010c03a8462e8a1ab89bea05938ba to your computer and use it in GitHub Desktop.
Change using 5s and 7s
def change(amount):
assert(24 <= amount <= 1000)
if amount == 24:
return [5, 5, 7, 7]
if amount == 25:
return [5, 5, 5, 5, 5]
if amount == 26:
return [5, 7, 7, 7]
if amount == 27:
return [5, 5, 5, 5, 7]
if amount == 28:
return [7, 7, 7, 7]
coins = change(amount - 5)
coins.append(5)
return coins
for n in range(24, 100):
print(f'{n}: {change(n)}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment