From 48054f3ba34b7add5f7a45ea42699ba9c8a08e2e Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 11 Dec 2022 11:59:54 -0500 Subject: Solve day 10 part 2 --- 2022/day10.awk | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to '2022/day10.awk') 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"; + } } -- cgit 1.4.1