diff --git a/day11.hs b/day11.hs index a46eb4b..14801a3 100644 --- a/day11.hs +++ b/day11.hs @@ -1,15 +1,15 @@ -import Control.Monad.State.Strict +import Control.Monad.State import Data.List -data M=M{n::[Int],w::Int,k::Int->Int,z::[Int]} l=map v=length (!)=drop +n(a,w,k,z)=a m"*"=(*);m"+"=(+) "old"%x=x;i%_=read i q[a,t,b]x=m t(a%x)(b%x) i#o=modify((\(f,(c:b))->f++(o c:b)).splitAt i) -c n o=product.take 2.reverse.sort.l w.(execState=<c{n=u:n c} -p[_,i,o,d,t,f]=M(read$'[':18!i++"]")0(q$words$19!o)(l(read.last.words)[d,t,f]) -s i o m=forM([0..i]>>[0..m-1])$ \i->(!!i)<$>get>>=(forM.n<*>b o)>>i# \c->c{n=[],w=w c+v(n c)} -main=interact$show.(\m->[c 9999(`mod`((product.l(head.z))m))m,c 19(`div`3)m]).l(p.filter(/="")).groupBy(const(/="")).lines +c n o=product.take 2.reverse.sort.l(\(_,a,_,_)->a).(execState=<(u:n,w,k,z) +p[_,i,o,d,t,f]=(read$'[':18!i++"]",0,q$words$19!o,l(read.last.words)[d,t,f]) +s i o m=forM([0..i]>>[0..m-1])$ \i->(!!i)<$>get>>=(forM.n<*>b o)>>i# \(n,w,k,z)->([],w+v n,k,z) +main=interact$show.(\m->[c 9999(`mod`(product.l(head. \(a,w,k,z)->z))m)m,c 19(`div`3)m]).l(p.filter(/="")).groupBy(\x->(/="")).lines