Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
tree-recursive solution to the counting change problem, pg. 41 SICP
countChange :: Integer -> [Integer] -> Integer
countChange amount denominations
| null denominations || amount < 0 = 0
| amount == 0 = 1
| otherwise = countChange amount (tail denominations) + countChange (amount - head denominations) denominations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.