Skip to content

Instantly share code, notes, and snippets.

@Ummon
Ummon / gist:3751687
Created September 19, 2012 19:26
Haskell > Scala
countChange :: Int -> [Int] -> Int
countChange money coins =
let
applyFactors factors = (if (sum $ zipWith (*) coins factors) == money then 1 else 0) +
if all (== money) factors then 0
else
applyFactors (nextFactors factors)
where
nextFactors (x : xs)
| x == money = 0 : (nextFactors xs)