Day 2: 232
This commit is contained in:
parent
f009aff1eb
commit
f75b36b26b
1 changed files with 3 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
|||
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]
|
||||
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=(+)
|
||||
main=interact$show.(<$>[p,q]).((\(a:b:_)->a*b).).flip(`foldl`[0,0,0]).map(fmap read.splitAt 1.map head.words).lines
|
Loading…
Add table
Reference in a new issue