22
[aoc20.git] / 6 / one.icl
1 module one
2
3 import StdEnv
4 import qualified Data.Foldable
5 import Data.List
6 import Text
7
8 read :: *File -> [Char]
9 read f
10 # (ok, l, f) = freadc f
11 | not ok = []
12 = [l:read f]
13
14 Start w
15 # (io, w) = stdio w
16 # ls = toString (read io)
17 = (both union ls, both intersect ls)
18
19 both :: ([Char] -> [Char] -> [Char]) -> (String -> Int)
20 both f = sum o map (length o 'Data.Foldable'.foldl1 f o map fromString o split "\n" o trim) o split "\n\n"