diff options
author | June McEnroe <june@causal.agency> | 2022-12-11 11:59:54 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2022-12-11 11:59:54 -0500 |
commit | 48054f3ba34b7add5f7a45ea42699ba9c8a08e2e (patch) | |
tree | 5c6c2ad4d243d3543253d9dae1b5b4c018bcc562 /2022 | |
parent | Solve day 10 part 1 (diff) | |
download | aoc-48054f3ba34b7add5f7a45ea42699ba9c8a08e2e.tar.gz aoc-48054f3ba34b7add5f7a45ea42699ba9c8a08e2e.zip |
Solve day 10 part 2
Diffstat (limited to '2022')
-rw-r--r-- | 2022/day10.awk | 11 |
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"; + } } |