From 89fda9b41c04380f724d27a86bc5f93dc69d41c1 Mon Sep 17 00:00:00 2001 From: Christoph Stahl Date: Sat, 4 Dec 2021 16:41:43 +0100 Subject: [PATCH] Day 4: 491 --- d4golf.hs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 d4golf.hs diff --git a/d4golf.hs b/d4golf.hs new file mode 100644 index 0000000..6446431 --- /dev/null +++ b/d4golf.hs @@ -0,0 +1,22 @@ +import Data.Either +m=map +z=zipWith +r=pure +l=Left +i=isRight +c=isLeft +e=[]:e +s[]=[] +s(v:t)|'.'>v=' ':s t|let=v:s t +v[]=[] +v s=tail(take 6 s):v(drop 6 s) +d%i|i==l d=r d|let=i +a=m.m.m.(%) +h=any$all i +x!d|h d||h(foldr(z(:))e d)=r$(x*)$sum$lefts=<z(?)a b)$drop(length(takeWhile(any c)i)-1)i +w p(n,t)=head$rights$p(n#t) +p(x:y)=(m read$words$s x,v$m(m(l.read).words)y) +main=interact$show.((,).w q<*>w(filter i=<<)).p.lines \ No newline at end of file