From e3e97bf59ab60cd396fc4b69fb0c847e48a33ace Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Mon, 3 Dec 2018 17:04:53 +0100 Subject: [PATCH] 3.2 --- 3/s1.icl | 2 +- 3/s2.icl | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 3/s2.icl diff --git a/3/s1.icl b/3/s1.icl index 122f505..6503ae2 100644 --- a/3/s1.icl +++ b/3/s1.icl @@ -1,4 +1,4 @@ -module s2 +module s1 import StdEnv import Data.Func diff --git a/3/s2.icl b/3/s2.icl new file mode 100644 index 0000000..a89c1aa --- /dev/null +++ b/3/s2.icl @@ -0,0 +1,39 @@ +module s2 + +import StdEnv +import Data.Func +import qualified Data.Set as DS +import Data.List +import Text + +getinput :: [Char] *File -> [[Char]] +getinput a f +# (ok, c, f) = freadc f +| not ok = if (a =: []) [] [reverse a] +| c == '\n' = [reverse a:getinput [] f] += getinput [c:a] f + +parse :: [Char] -> (Int, [(Int, Int)]) +parse c = case split " " (toString c) of + [i,_, offset,size] + # [offsetx:offsety:_] = split "," offset + # offsety = offsety % (0, textSize offsety-2) + # [sizex:sizey:_] = split "x" size + = (toInt i, [ (x, y) + \\x<-[toInt offsetx+1..toInt offsetx+toInt sizex] + , y<-[toInt offsety+1..toInt offsety+toInt sizey] + ]) + _ = abort "bork" + +Start w +# (io, w) = stdio w += proc $ map parse $ getinput [] io + +proc [x:xs] = p x xs +where + p (i, cs) rest=:[x:xs] + | 'DS'.null $ 'DS'.intersection ('DS'.fromList cs) $ 'DS'.fromList $ flatten $ map snd rest = i + | not (trace_t ".") = undef + = p x $ xs ++ [(i,cs)] + +import StdDebug -- 2.20.1