summary refs log tree commit diff homepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--2022/day01.awk20
1 files changed, 17 insertions, 3 deletions
diff --git a/2022/day01.awk b/2022/day01.awk
index c81d624..0fbde52 100644
--- a/2022/day01.awk
+++ b/2022/day01.awk
@@ -1,10 +1,24 @@
 /[[:digit:]]+/ {
 	cals += $1;
 }
-/^$/ {
-	if (cals > max) max = cals;
+function push() {
+	if (cals > max1) {
+		max3 = max2;
+		max2 = max1;
+		max1 = cals;
+	} else if (cals > max2) {
+		max1 = max2;
+		max2 = cals;
+	} else if (cals > max3) {
+		max3 = cals;
+	}
 	cals = 0;
 }
+/^$/ {
+	push();
+}
 END {
-	print max;
+	push();
+	print max1;
+	print max1 + max2 + max3;
 }
500'>2020-02-10Update line count for words longer than linesJune McEnroe 2020-02-10Simplify mark, heat, unread trackingJune McEnroe 2020-02-10Update prompt when own nick changesJune McEnroe 2020-02-10Match URLs surrounded by parenthesesJune McEnroe 2020-02-10Fix M-a so it properly cycles back to where it startedJune McEnroe 2020-02-09Add M-lJune McEnroe 2020-02-09Add /whoisJune McEnroe 2020-02-09Add /msgJune McEnroe