diff options
Diffstat (limited to 'challenge-239/deadmarshal/haskell/ch2.hs')
| -rw-r--r-- | challenge-239/deadmarshal/haskell/ch2.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/challenge-239/deadmarshal/haskell/ch2.hs b/challenge-239/deadmarshal/haskell/ch2.hs new file mode 100644 index 0000000000..2b5a26f6ee --- /dev/null +++ b/challenge-239/deadmarshal/haskell/ch2.hs @@ -0,0 +1,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" + |
