Last active
November 4, 2016 21:56
-
-
Save codecontemplator/6ba276b708ec3a8fc38e897ef6314680 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
solve xs t = nub $ map sort $ solve' xs [] t | |
where | |
solve' _ solution 0 = [solution] | |
solve' [] _ _ = [] | |
solve' (x:xs) solution t = solve' xs (x:solution) (t-x) ++ solve' xs solution t | |
test = solve [1,3,3,3,9] 10 | |
--[[3,3,3,1],[9,1]] | |
test2 = solve [1,3,3,4,5,3,9] 10 | |
--[[1,3,3,3],[1,4,5],[1,9],[3,3,4]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment