Day 9: 441
This commit is contained in:
parent
998dadcce8
commit
b9f7afeb25
1 changed files with 9 additions and 0 deletions
9
d9golf.hs
Normal file
9
d9golf.hs
Normal file
|
@ -0,0 +1,9 @@
|
|||
import Data.List
|
||||
m!(a,b)|a>=0,b>=0,a<length m,c<-m!!a,b<length c=c!!b|let=9
|
||||
z m=(=<<)(m%)$(,)<$>[0..length m]<*>[0..length(m!!0)]
|
||||
m%p=[(p,m!p)|all((m!p<).(m!))$f p]
|
||||
f(x,y)=zip[x+1,x,x,x-1][y,y+1,y-1,y]
|
||||
x m g p|p`elem`g=[]|let=p:filter((/=9).(m!))(f p)
|
||||
m#g|v<-nub$(=<<)(\v->x m(g\\[v])v)g=last$m#v:[g|v==g]
|
||||
b i=product.take 3.reverse.sort.map(length.(i#).pure.fst)$z i
|
||||
main=interact$show.((,).b<*>sum.map((+1).snd).z).map(map$read.pure).lines
|
Loading…
Add table
Reference in a new issue