diff options
Diffstat (limited to '2022/10/puzzle-2.awk')
-rwxr-xr-x | 2022/10/puzzle-2.awk | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/2022/10/puzzle-2.awk b/2022/10/puzzle-2.awk new file mode 100755 index 0000000..31a9ea6 --- /dev/null +++ b/2022/10/puzzle-2.awk @@ -0,0 +1,15 @@ +#!/usr/bin/awk -f + +BEGIN { x = 1 } + +{ + for (i = 0; i < ($1 == "addx" ? 2 : 1); i++) { + p = (++c % 40) - 1 + if (p == -1) + p = 39 + printf (p == x - 1 || p == x || p == x + 1) ? "█" : " " + if (p == 39) + print "" + } +} +/addx/ { x += $2 } |