From 4f5b004db9a93d9ff356cdd3e6a9fa40421628a7 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Mon, 13 Dec 2021 11:21:48 +0100 Subject: Make code less shit --- 2021/13/puzzles.awk | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to '2021') 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 } -- cgit v1.2.3