aboutsummaryrefslogtreecommitdiff
path: root/2021/10/puzzle-2.sed
blob: 887386c5ff7e8d7b427203c765ef63382c08015e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
:top
s/()//
s/\[\]//
s/{}//
s/<>//
t top

/[])}>]/d

:loop
s/\([(\[{<]*\)($/s = s * 5 + 1;\1/
s/\([(\[{<]*\)\[$/s = s * 5 + 2;\1/
s/\([(\[{<]*\){$/s = s * 5 + 3;\1/
s/\([(\[{<]*\)<$/s = s * 5 + 4;\1/
t loop

s/^/s = 0;/
s/$/s/