Created
December 11, 2018 01:04
-
-
Save robmoore/78d010c03a8462e8a1ab89bea05938ba to your computer and use it in GitHub Desktop.
Change using 5s and 7s
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
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