From fbee8c65aa88b94e97b2cb6b29f615859bf34660 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 11 Dec 2022 23:27:34 +0100 Subject: Add 2022 day 10 solutions --- 2022/10/puzzle-2.awk | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 2022/10/puzzle-2.awk (limited to '2022/10/puzzle-2.awk') 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 } -- cgit v1.2.3