diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0721bc5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +!*.hs diff --git a/three.hs b/three.hs new file mode 100644 index 0000000..dcc0e05 --- /dev/null +++ b/three.hs @@ -0,0 +1,15 @@ + +splitlist :: [a] -> ([a],[a]) +splitlist list = (take n list,drop n list) + where n = (length list) `div` 2 + +inBoth :: (Eq a) => ([a],[a]) -> [a] +inBoth (first,second) = do + inFirst <- first + if (inFirst `elem` second) then return inFirst else [] + + + +main = do + input <- readFile "three-input.txt" + print $ map ( inBoth . splitlist ) $ lines input