aboutsummaryrefslogtreecommitdiff
path: root/2021
diff options
context:
space:
mode:
Diffstat (limited to '2021')
-rw-r--r--2021/13/puzzles.awk17
1 files changed, 3 insertions, 14 deletions
diff --git a/2021/13/puzzles.awk b/2021/13/puzzles.awk
index 2450eab..8c149d7 100644
--- a/2021/13/puzzles.awk
+++ b/2021/13/puzzles.awk
@@ -7,24 +7,13 @@ BEGIN { FS = ",|=" }
flag == 1 { next }
# END PART 1
-/x/ {
+/x|y/ {
for (y in grid) {
for (x in grid[y]) {
- if (x * 1 > $2) {
+ if ($1 ~ /x/ && x * 1 > $2) {
delete grid[y][x]
grid[y][$2 - (x - $2)] = 1
- }
- }
- }
- # START PART 1
- flag = 1
- # END PART 1
-}
-
-/y/ {
- for (y in grid) {
- if (y * 1 > $2) {
- for (x in grid[y]) {
+ } else if ($1 ~ /y/ && y * 1 > $2) {
delete grid[y][x]
grid[$2 - (y - $2)][x] = 1
}