Day 5: 378 (now with code, and without binary)

This commit is contained in:
Christoph Stahl 2022-12-05 18:29:44 +01:00
parent 8c0efe2162
commit 4dce5f6023
2 changed files with 12 additions and 0 deletions

BIN
day5

Binary file not shown.

12
day5.hs Normal file
View file

@ -0,0 +1,12 @@
import Data.List
m=map
z=splitAt
f=filter(>'@')
x%[i,s,t]=u t$d i s x
i(_:x:y)=read x:i y;i _=[]
t(_:a:_:_:x)=a:t x;t(_:a:x)=[a]
u s(a,x)|(t,r:d)<-z(s-1)x=t++(a++r):d
x#[i,s,t]|i<1=x|let=(x%[1,s,t])#[i-1,s,t]
q r(a,_:b)=foldl r(m f$t$transpose a)$m(i.words)b
d n s x|(t,v:d)<-z(s-1)x,(h,r)<-z n v=(h,t++(r:d))
main=interact$show.(\i->m(m head.($i))[q(#),q(%)]).span(/=[]).lines