start with three

This commit is contained in:
qvalentin 2022-12-10 18:50:02 +01:00
parent 29efc1f0e8
commit 018d194796
Signed by: qvalentin
GPG Key ID: C979FA1EAFCABF1C
2 changed files with 16 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
!*.hs

15
three.hs Normal file
View File

@ -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