start with three
This commit is contained in:
parent
29efc1f0e8
commit
018d194796
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
!*.hs
|
15
three.hs
Normal file
15
three.hs
Normal 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
|
Loading…
Reference in a new issue