From 22f2d0cfcb9729300a4768a8592d77a12b1c2eeb Mon Sep 17 00:00:00 2001 From: Christoph Stahl Date: Sat, 4 Dec 2021 17:26:34 +0100 Subject: [PATCH] Day 4: 470 --- d4golf.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/d4golf.hs b/d4golf.hs index 6446431..872edc6 100644 --- a/d4golf.hs +++ b/d4golf.hs @@ -6,17 +6,16 @@ l=Left i=isRight c=isLeft e=[]:e -s[]=[] -s(v:t)|'.'>v=' ':s t|let=v:s t +s(v:t)|'.'>v=[]:s t|(x:u)<-s t=(v:x):u v[]=[] v s=tail(take 6 s):v(drop 6 s) -d%i|i==l d=r d|let=i -a=m.m.m.(%) +k d i|i==l d=r d|let=i +a=m.m.m.k 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 +q i=(\(b,h:_)->z(?)(last b)h)$span(any c)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) +p(x:y)=(m read$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