aboutsummaryrefslogtreecommitdiff
path: root/2021/05/puzzles.awk
diff options
context:
space:
mode:
authorThomas Voss <thomasvoss@live.com> 2021-12-05 06:55:38 +0100
committerThomas Voss <thomasvoss@live.com> 2021-12-05 06:55:38 +0100
commit32aa78e52d5908ee190961b51c4afdca4d287a8e (patch)
treebf6612c6fe6a9d17d3f9a0a15f8263de3a128b0d /2021/05/puzzles.awk
parent32c8ac4d91ae26f07c54203886fbf9c7a2bb221a (diff)
Slight performance improvement
Diffstat (limited to '2021/05/puzzles.awk')
-rw-r--r--2021/05/puzzles.awk8
1 files changed, 4 insertions, 4 deletions
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 {