From 94612e6674c5c4aa1838968c1286e9965b14d56b Mon Sep 17 00:00:00 2001 From: Christoph Stahl Date: Sun, 11 Dec 2022 16:34:10 +0100 Subject: [PATCH] Day 11: 659 --- day11.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 day11.hs diff --git a/day11.hs b/day11.hs new file mode 100644 index 0000000..a46eb4b --- /dev/null +++ b/day11.hs @@ -0,0 +1,15 @@ +import Control.Monad.State.Strict +import Data.List +data M=M{n::[Int],w::Int,k::Int->Int,z::[Int]} +l=map +v=length +(!)=drop +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