2
[advent18.git] / 2 / s1.icl
1 module s1
2
3 import StdEnv
4
5 import Data.Func
6 import Data.List
7
8 getinput f
9 # (ok, c, f) = freadc f
10 | not ok = []
11 = [c:getinput f]
12
13 split :: [Char] [Char] -> [[Char]]
14 split [] [] = []
15 split c [] = [reverse c]
16 split c ['\n':rest] = [reverse c:split [] rest]
17 split c [r:rest] = split [r:c] rest
18
19 Start w
20 # (io, w) = stdio w
21 # l = map (nub o map length o group o sort)
22 $ split []
23 $ getinput io
24 = ns 2 l * ns 3 l
25
26 ns n l = sum [1\\x<-l|isMember n x]