Day 2: 229

This commit is contained in:
Christoph Stahl 2021-12-04 01:07:33 +01:00
parent e55fee94b1
commit 41711114e9

View file

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