Skip to content

Instantly share code, notes, and snippets.

@AphonicChaos
Created February 24, 2016 14:23
Show Gist options
  • Save AphonicChaos/817e6aa3e292e12f397f to your computer and use it in GitHub Desktop.
Save AphonicChaos/817e6aa3e292e12f397f to your computer and use it in GitHub Desktop.
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