Created
February 24, 2016 14:23
-
-
Save AphonicChaos/817e6aa3e292e12f397f 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
module Main where | |
import Util (unzipWith) | |
count :: [(Bool, Bool)] | |
count = do | |
d1 <- [1..8] | |
d2 <- [1..8] | |
d3 <- [1..8] | |
d4 <- [1..8] | |
let sum3ok = sum([d1, d2, d3]) == 8 | |
let sum4ok = sum([d1, d2, d4]) == 8 | |
return (sum3ok, sum4ok) | |
-- the original definition | |
met = length $ filter id $ map (uncurry (||)) count | |
-- with unzipWith | |
met' = length $ filter id $ unzipWith (||) count | |
main :: IO () | |
main = do | |
print met | |
print met' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment