Day 4: 198

This commit is contained in:
Christoph Stahl 2022-12-04 13:43:29 +01:00
parent 1677642df3
commit 539a031bad
3 changed files with 1011 additions and 0 deletions

5
day4.hs Normal file
View file

@ -0,0 +1,5 @@
p q l=sum[1|i<-l,q i>=0]
v c l|(h,_:t)<-break(==c)l=[h,t]
d[a,b,c,d]|a<c=b-d|a==c=0|let=d-b
e[a,b,c,d]|a<c=b-c|a==c=0|let=d-a
main=interact$show.((,).p d<*>p e).map((map read.v '-'=<<).v ',').lines

1000
day4long Normal file

File diff suppressed because it is too large Load diff

6
day4short Normal file
View file

@ -0,0 +1,6 @@
2-4,6-8
2-3,4-5
5-7,7-9
2-8,3-7
6-6,4-6
2-6,4-8