Day 10: 290

This commit is contained in:
Christoph Stahl 2021-12-10 20:59:17 +01:00
parent 00aa54c6cc
commit 94de56b7b8

View file

@ -2,7 +2,7 @@ import Data.List
e=fromEnum
n%(h:t)|h`elem`"([{<"=(h:n)%t|i:s<-n,abs(e h-e i)<3=s%t|let=(0,a[h])
n%_=(foldl((+).(5*))0$b<$>n,0)
a")"=3;a"]"=57;a"}"=1197;a">"=25137
a")"=3;a"]"=57;a"}"=1197;a _=25137
b '('=1;b '['=2;b '{'=3;b _=4
c(x,y)=((!!)<*>(`div`2).length$filter(>0)$sort x,sum y)
main=interact$show.c.unzip.map(""%).lines