Day 4: rearranged
This commit is contained in:
parent
22f2d0cfcb
commit
355609ae28
1 changed files with 10 additions and 11 deletions
21
d4golf.hs
21
d4golf.hs
|
@ -1,21 +1,20 @@
|
||||||
import Data.Either
|
import Data.Either
|
||||||
m=map
|
m=map
|
||||||
z=zipWith
|
e=[]:e
|
||||||
r=pure
|
r=pure
|
||||||
l=Left
|
l=Left
|
||||||
i=isRight
|
|
||||||
c=isLeft
|
c=isLeft
|
||||||
e=[]:e
|
z=zipWith
|
||||||
s(v:t)|'.'>v=[]:s t|(x:u)<-s t=(v:x):u
|
i=isRight
|
||||||
v[]=[]
|
|
||||||
v s=tail(take 6 s):v(drop 6 s)
|
|
||||||
k d i|i==l d=r d|let=i
|
|
||||||
a=m.m.m.k
|
a=m.m.m.k
|
||||||
h=any$all i
|
h=any$all i
|
||||||
x!d|h d||h(foldr(z(:))e d)=r$(x*)$sum$lefts=<<d|let=l 0
|
|
||||||
(x:y)#f=m(x!)(a x f):y#a x f
|
|
||||||
a?b|c a,i b=b|let=l 0
|
a?b|c a,i b=b|let=l 0
|
||||||
q i=(\(b,h:_)->z(?)(last b)h)$span(any c)i
|
k d i|i==l d=r d|let=i
|
||||||
w p(n,t)=head$rights$p(n#t)
|
w p(n,t)=head$rights$p(n#t)
|
||||||
|
(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)
|
p(x:y)=(m read$s x,v$m(m(l.read).words)y)
|
||||||
main=interact$show.((,).w q<*>w(filter i=<<)).p.lines
|
q i=(\(b,h:_)->z(?)(last b)h)$span(any c)i
|
||||||
|
main=interact$show.((,).w q<*>w(filter i=<<)).p.lines
|
||||||
|
x!d|h d||h(foldr(z(:))e d)=r$(x*)$sum$lefts=<<d|let=l 0
|
Loading…
Add table
Reference in a new issue