Day 4: 419

This commit is contained in:
Christoph Stahl 2021-12-05 01:07:57 +01:00
parent 8796296a27
commit 65450ca033

View file

@ -1,18 +1,16 @@
import Data.Either import Data.Either
e=[]:e e=[]:e
j=all i
a=m.m.m.k a=m.m.m.k
h=any$all i
w p=head.rights.p w p=head.rights.p
a?b|c a,i b=b|let=l 0 k d i|i==l d=pure d|let=i
k d i|i==l d=r d|let=i a?b|(not.i)a,i b=b|let=l 0
(x:y)#f=m(x!)(a x f):y#a x f (x:y)#f=m(x!)(a x f):y#a x f
a&x|(u,_:v)<-break(==x)a=u:v&x|let=[a] a&x|(u,_:v)<-break(==x)a=u:v&x|let=[a]
p(x:(_:y))=m read(x&',')#(m(m(l.read).words)y&[]) p(x:(_:y))=m read(x&',')#(m(m(l.read).words)y&[])
x!d|h d||h(foldr(z(:))e d)=r$(x*)$sum$lefts=<<d|let=l 0 x!d|any j d||any j(foldr(z(:))e d)=pure$(x*)$sum$lefts=<<d|let=l 0
main=interact$show.((,).w((\(b,h:_)->z(?)(last b)h).span(any c))<*>w(filter i=<<)).p.lines main=interact$show.((,).w((\(b,h:_)->z(?)(last b)h).break j)<*>w(filter i=<<)).p.lines
m=map m=map
r=pure
l=Left l=Left
c=isLeft
z=zipWith z=zipWith
i=isRight i=isRight