Day 2: 233

This commit is contained in:
Christoph Stahl 2021-12-02 17:34:04 +01:00
parent 051065f189
commit f009aff1eb

View file

@ -1,3 +1,3 @@
q(h:f:_)(d,n)|"f"<d=[h-n,f]|"f">d=[h+n,f]|let=[h,f+n]
p[h,f,a](d,n)|"f"<d=[h,f,a-n]|"f">d=[h,f,a+n]|let=[h+n,f+n*a,a]
main=interact$show.(<$>[p,q]).((product.take 2).).flip(`foldl`[0,0,0]).map(fmap read.splitAt 1.map head.words).lines
main=interact$show.(<$>[p,q]).((\(a:b:_)->a*b).).flip(`foldl`[0,0,0]).map(fmap read.splitAt 1.map head.words).lines