aboutsummaryrefslogtreecommitdiff
path: root/2022/01/puzzle-2.awk
blob: 61860845f6a0701ae13c59de1cf4e1972b789d13 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/awk -f

/[0-9]+/ { acc += $1 }
!/./ {
	if (acc > max[1]) {
		max[3] = max[2];
		max[2] = max[1];
		max[1] = acc;
	} else if (acc > max[2]) {
		max[3] = max[2];
		max[2] = acc;
	} else if (acc > max[3])
		max[3] = acc;
	acc = 0
}

END { print max[1] + max[2] + max[3] }