Skip to content

Instantly share code, notes, and snippets.

@DeaconDesperado
Created November 1, 2013 00:39
Show Gist options
  • Save DeaconDesperado/7259493 to your computer and use it in GitHub Desktop.
Save DeaconDesperado/7259493 to your computer and use it in GitHub Desktop.
Permutations of a dollar
object Change extends App {
def permuteCombinations(n:Integer,coins:Array[Integer]):Integer = {
if(n == 0) 1
else if(coins.isEmpty || n < 0) 0
else {
permuteCombinations(n - coins.head, coins) + permuteCombinations(n, coins.tail)
}
}
println(permuteCombinations(100,Array(1,5,10,25,50,100)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment