Day 5v2: 278
This commit is contained in:
parent
4ce7a70666
commit
aff7713c68
1 changed files with 6 additions and 7 deletions
13
d5golf2.hs
13
d5golf2.hs
|
@ -1,8 +1,7 @@
|
|||
import Data.List
|
||||
m=map;(!)=splitAt
|
||||
p[s,_,t]=m(m read.(&','))[s,t]
|
||||
v[[a,b],[c,d]]=a==c||b==d
|
||||
a&x|(u,_:v)<-break(==x)a=u:v&x|let=[a]
|
||||
n[[x,y],[a,b]]|x/=a||y/=b=(x,y):n[[(x?a),(y?b)],[a,b]]|let=[(x,y)]
|
||||
x1?x2|x1>x2=x1-1|x1<x2=x1+1|let=x1
|
||||
main=interact$show.m(length.filter (>1).map length.group.sort.(n=<<)).(\x->[x,filter v x]).m(p.words).lines
|
||||
m=map;l=length;f=filter
|
||||
v[a,b]=or$zipWith(==)a b
|
||||
x?y|x>y=x-1|x<y=x+1|let=x
|
||||
z a|(x,_:y)<-break(<'.')a=m read[x,y]
|
||||
n[f@[x,y],d@[a,b]]|x==a,y==b=[f]|let=f:n[[x?a,y?b],d]
|
||||
main=interact$show.m(l.f(>1).m l.group.sort.(n=<<)).(\x->[x,f v x]).m(m z.f(>".").words).lines
|
Loading…
Add table
Reference in a new issue