From a49b79d43228cea883729afaf5ec8d0067ad7a9d Mon Sep 17 00:00:00 2001 From: Christoph Stahl Date: Sat, 4 Dec 2021 17:45:19 +0100 Subject: [PATCH] Day 4: 454 --- d4golf.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/d4golf.hs b/d4golf.hs index d769ae6..6c89406 100644 --- a/d4golf.hs +++ b/d4golf.hs @@ -4,12 +4,11 @@ a=m.m.m.k h=any$all i a?b|c a,i b=b|let=l 0 k d i|i==l d=r d|let=i -w p(n,t)=head$rights$p(n#t) +w p=head.rights.p (x:y)#f=m(x!)(a x f):y#a x f v[]=[];v s=tail(take 6 s):v(drop 6 s) s(v:t)|'.'>v=[]:s t|(x:u)<-s t=(v:x):u -p(x:y)=(m read$s x,v$m(m(l.read).words)y) -q i=(\(b,h:_)->z(?)(last b)h)$span(any c)i +p(x:y)=m read(s x)#v(m(m(l.read).words)y) m=map;r=pure;l=Left;c=isLeft;z=zipWith;i=isRight -main=interact$show.((,).w q<*>w(filter i=<<)).p.lines -x!d|h d||h(foldr(z(:))e d)=r$(x*)$sum$lefts=<z(?)(last b)h).span(any c))<*>w(filter i=<<)).p.lines \ No newline at end of file