Day 11: 482

This commit is contained in:
Christoph Stahl 2021-12-13 22:38:08 +01:00
parent 94de56b7b8
commit c8a1a9cdde

14
d11golf.hs Normal file
View file

@ -0,0 +1,14 @@
m=map.map
(?)=splitAt
w=filter
y=maybe
n=Nothing
v g m(x,y)|x>=0,y>=0,(f,r:b)<-x?m,(h,c:t)<-y?r=f++(h++g c:t):b|let=m
s(x,y)=(,)<$>[x-1..x+1]<*>[y-1..y+1]
m#(x,y)=m!!x!!y
a=[0..9]
p!m=w(p.(m#))$(,)<$>a<*>a
(%)i j z=((i+1,j+length((==n)!z)),m(y 0 id)z)
t((n,j),i)=n%j$l$m(pure.(+1))i
l i|a@(h:t)<-y(2<1)(>9)!i=l$foldl(v((+1)<$>))(foldl(v(pure n))i a)$s=<<a|let=i
main=interact$show.((,).(fst.fst.(head.w(all(==0).concat.snd)))<*>snd.fst.(!!100)).iterate t.(,)(0,0).m(read.pure).lines