From b48d16308e4d85c5669e5719b6c512d5aba42818 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Sun, 2 Dec 2018 11:11:25 +0100 Subject: [PATCH] 2.2 --- 2/s2.icl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 2/s2.icl diff --git a/2/s2.icl b/2/s2.icl new file mode 100644 index 0000000..7c02f7c --- /dev/null +++ b/2/s2.icl @@ -0,0 +1,30 @@ +module s2 + +import StdEnv + +import Data.Func +import Data.List +import Data.Tuple + +getinput f +# (ok, c, f) = freadc f +| not ok = [] += [c:getinput f] + +split :: [Char] [Char] -> [[Char]] +split [] [] = [] +split c [] = [reverse c] +split c ['\n':rest] = [reverse c:split [] rest] +split c [r:rest] = split [r:c] rest + +Start w +# (io, w) = stdio w += map (map fst o filter (uncurry (==)) o zip) + $ flatten + $ filter (not o isEmpty) + $ proc + $ split [] + $ getinput io + +proc [] = [] +proc [x:xs] = [[(e, x)\\e<-xs | length [()\\a<-x & b<-e | a<>b] <= 1]:proc xs] -- 2.20.1