aboutsummaryrefslogtreecommitdiff
path: root/challenge-239/deadmarshal/haskell/ch2.hs
blob: 2b5a26f6ee27f0907385b9e4aa7c8886ddd70cd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
module Ch2 where

consistentStrings :: [String] -> String -> Int
consistentStrings xs allowed =
  length $ filter (==True) $ map (\s -> cond s) xs
  where
    cond s = all (\c -> elem c allowed) s
    
main :: IO ()
main = do
  print $ consistentStrings ["ad","bd","aaab","baa","badab"] "ab"
  print $ consistentStrings ["a","b","c","ab","ac","bc","abc"] "abc"
  print $ consistentStrings ["cc","acd","b","ba","bac","bad","ac","d"] "cad"