Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- coins = [2, 3, 7]
- change :: Integer -> [[Integer]]
- change n = foldl (\acc x -> acc ++ (nub $ permutations x)) [] result
- where result = change' coins n
- change' :: [Integer] -> Integer -> [[Integer]]
- change' _ 0 = [[]]
- change' [] _ = []
- change' xxs@(x:xs) n
- | n >= x = map (x:) (change' xxs (n - x)) ++ change' xs n
- | otherwise = change' xs n
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement