1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| f<< /aoc/core.fs
f" /aoc/input"
0 value most
0 value second
0 value third
0 value current
: update-top3 ( n -- )
case
most > of most to second second to third r@ to most endof
second > of second to third r@ to second endof
third > of r@ to third endof
endcase
;
: parseline ( s -- )
dup c@ if parse drop to+ current
else
current update-top3
0 to current
then ;
: solve
['] parseline maplines
most . nl>
most second third + + . nl> ;
solve
|