From 231b40909b5a3c2e202bcb48ab40e42a4213bdff Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 2 Dec 2022 15:27:20 +0100 Subject: Add another gawk solution --- 2022/01/puzzles.awk | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 2022/01/puzzles.awk (limited to '2022/01/puzzles.awk') diff --git a/2022/01/puzzles.awk b/2022/01/puzzles.awk new file mode 100755 index 0000000..11bece5 --- /dev/null +++ b/2022/01/puzzles.awk @@ -0,0 +1,12 @@ +#!/usr/bin/gawk -f + +BEGIN { RS = ""; FS = "\n" } + { for (i = 1; i <= NF; i++) s[NR] += $i } +END { + asort(s) + # START PART 1 + print s[NR] + # END PART 1 START PART 2 + print s[NR] + s[NR - 1] + s[NR - 2] + # END PART 2 +} -- cgit v1.2.3