Skip to content

Instantly share code, notes, and snippets.

@ColinEberhardt
Created December 1, 2014 13:50
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 ColinEberhardt/f4ccea8ca640f38a3755 to your computer and use it in GitHub Desktop.
Save ColinEberhardt/f4ccea8ca640f38a3755 to your computer and use it in GitHub Desktop.
countChange
def countChange(money: Int, coins: List[Int]): Int =
if (coins.isEmpty || money < 0)
0
else if (money == 0)
1
else
countChange(money - coins.head, coins) +
countChange(money, coins.tail)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment