Skip to content

Instantly share code, notes, and snippets.

@phsteve
Last active December 27, 2015 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phsteve/7295327 to your computer and use it in GitHub Desktop.
Save phsteve/7295327 to your computer and use it in GitHub Desktop.
My recursive change counting algorithm.
#n is the total amount, L is the list of change denominations.
def change(n, L):
if n < 0:
return 0
if n == 0:
return 1
if L == []:
return 0
return change(n, L[:-1]) + change(n-L[-1], L)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment