summary refs log tree commit diff homepage
path: root/2022
diff options
context:
space:
mode:
Diffstat (limited to '2022')
-rw-r--r--2022/day10.awk11
1 files changed, 11 insertions, 0 deletions
diff --git a/2022/day10.awk b/2022/day10.awk
index 7788b17..5589a1c 100644
--- a/2022/day10.awk
+++ b/2022/day10.awk
@@ -6,6 +6,11 @@ function cycle() {
 	if (cycles == 20 || (cycles-20) % 40 == 0) {
 		sum += cycles * X;
 	}
+	crt[+x,+y] = ((X >= x-1 && X <= x+1) ? "#" : ".");
+	if (++x == 40) {
+		y++;
+		x = 0;
+	}
 	cycles++;
 }
 /addx/ {
@@ -18,4 +23,10 @@ function cycle() {
 }
 END {
 	print sum;
+	for (y = 0; y < 6; ++y) {
+		for (x = 0; x < 40; ++x) {
+			printf "%s", crt[x,y];
+		}
+		printf "\n";
+	}
 }