Day 4: 424, Christmas tree (sort of)
This commit is contained in:
parent
c5519a865d
commit
8796296a27
1 changed files with 9 additions and 5 deletions
14
d4golf.hs
14
d4golf.hs
|
@ -6,9 +6,13 @@ w p=head.rights.p
|
|||
a?b|c a,i b=b|let=l 0
|
||||
k d i|i==l d=r d|let=i
|
||||
(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)
|
||||
m=map;r=pure;l=Left;c=isLeft;z=zipWith;i=isRight
|
||||
a&x|(u,_:v)<-break(==x)a=u:v&x|let=[a]
|
||||
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
|
||||
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).span(any c))<*>w(filter i=<<)).p.lines
|
||||
m=map
|
||||
r=pure
|
||||
l=Left
|
||||
c=isLeft
|
||||
z=zipWith
|
||||
i=isRight
|
Loading…
Add table
Reference in a new issue