Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Stones Riddle (Beginners Haskell), see
import Data.List
allStones = [[a,b,c,d]| a <- [1..39], b <- [a..39], c <- [b..39], d <- [c..39], a+b+c+d==40]
combineWeights [x] = [-x, 0, x]
combineWeights (x:xs) = concat $ map (\w -> [w-x, w, w+x]) (combineWeights xs)
result = filter (\x -> ((sort $ filter (>0) $ nub $ map abs (combineWeights x)) == [1..40])) allStones
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.