Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.34 KB | None | 0 0
  1.   def countChange(money: Int, coins: List[Int]): Int = {
  2.     if (coins.isEmpty) 0
  3.     else if (money == 0) 1
  4.     else if (money >= coins.head && !coins.isEmpty) countChange(money - coins.head, coins) + countChange(money - coins.head, coins.tail)
  5.     else if (money < coins.head && !coins.isEmpty) countChange(money, coins.tail)
  6.     else 0
  7.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement