From 5efcc8160c38889eaa70cf2f10089e9d2d1450b5 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 2 Dec 2024 22:41:22 +0100 Subject: Refactor --- 2024/02/puzzles.awk | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to '2024/02/puzzles.awk') diff --git a/2024/02/puzzles.awk b/2024/02/puzzles.awk index 789a193..da9ac93 100644 --- a/2024/02/puzzles.awk +++ b/2024/02/puzzles.awk @@ -27,23 +27,17 @@ function check(skip, xs, s, i, j, d, D) } # START PART 1 -{ - s = sign($1 - $2) - n += check() -} +{ n += check() } # END PART 1 START PART 2 -{ - s = sign($1 - $2) - if (!check()) { - for (i = 1; i <= NF; i++) { - if (check(i)) - break - } - if (i > NF) - next +!check() { + for (i = 1; i <= NF; i++) { + if (check(i)) + break } - n++ + if (i > NF) + next } +{ n++ } # END PART 2 END { print n } \ No newline at end of file -- cgit v1.2.3