From 32aa78e52d5908ee190961b51c4afdca4d287a8e Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 5 Dec 2021 06:55:38 +0100 Subject: Slight performance improvement --- 2021/05/puzzles.awk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to '2021/05') diff --git a/2021/05/puzzles.awk b/2021/05/puzzles.awk index 5710a92..f735249 100644 --- a/2021/05/puzzles.awk +++ b/2021/05/puzzles.awk @@ -8,10 +8,10 @@ $2 == $4 && $1 <= $3 { while ($1 <= $3) grid[$2][$1++]++; next } $2 == $4 { while ($3 <= $1) grid[$2][$3++]++; next } # START PART 2 -$1 <= $3 && $2 <= $4 { while (!($1 > $3)) grid[$2++][$1++]++; next } -$1 <= $3 { while (!($1 > $3)) grid[$2--][$1++]++; next } -$2 <= $4 { while (!($1 < $3)) grid[$2++][$1--]++; next } - { while (!($1 < $3)) grid[$2--][$1--]++; next } +$1 <= $3 && $2 <= $4 { while ($1 <= $3) grid[$2++][$1++]++; next } +$1 <= $3 { while ($1 <= $3) grid[$2--][$1++]++; next } +$2 <= $4 { while ($1 >= $3) grid[$2++][$1--]++; next } + { while ($1 >= $3) grid[$2--][$1--]++; next } # END PART 2 END { -- cgit v1.2.3