3.2
[advent18.git] / 1 / s2.icl
1 module s2
2
3 import StdEnv
4
5 import Data.Func
6 import qualified Data.Set as DS
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 = proc 'DS'.newSet
22 $ scan (+) 0
23 $ map (toInt o toString)
24 $ flatten
25 $ repeat
26 $ split []
27 $ getinput io
28
29 proc have [x:xs]
30 | 'DS'.member x have = x
31 = proc ('DS'.insert x have) xs