aboutsummaryrefslogtreecommitdiff
path: root/2022
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2022-12-11 23:27:34 +0100
committerThomas Voss <mail@thomasvoss.com> 2022-12-11 23:27:34 +0100
commitfbee8c65aa88b94e97b2cb6b29f615859bf34660 (patch)
treefe9dba897bc91cb12ceb20f5ba56a8a4f0c9dd8f /2022
parent603fb558d957201754cc3e64004f83e2f9ff4745 (diff)
Add 2022 day 10 solutions
Diffstat (limited to '2022')
-rw-r--r--2022/10/input143
-rwxr-xr-x2022/10/puzzle-1.awk8
-rwxr-xr-x2022/10/puzzle-2.awk15
3 files changed, 166 insertions, 0 deletions
diff --git a/2022/10/input b/2022/10/input
new file mode 100644
index 0000000..b6b8a79
--- /dev/null
+++ b/2022/10/input
@@ -0,0 +1,143 @@
+addx 1
+addx 4
+noop
+noop
+addx 30
+addx -24
+addx -1
+noop
+addx 4
+addx 1
+addx 5
+addx -4
+addx 5
+addx 4
+addx 1
+noop
+addx 5
+addx -1
+addx 5
+addx 3
+noop
+addx -38
+addx 9
+addx -4
+noop
+addx 3
+noop
+addx 2
+addx 3
+noop
+addx 2
+addx 3
+noop
+addx 2
+addx 3
+noop
+addx 2
+addx -17
+addx 22
+addx -2
+addx 5
+addx 2
+addx 3
+addx -2
+addx -36
+noop
+addx 5
+noop
+addx 3
+noop
+addx 2
+addx -5
+noop
+addx 10
+addx 3
+addx -2
+addx 3
+addx 2
+addx 4
+noop
+noop
+noop
+noop
+addx 3
+noop
+noop
+addx 7
+addx 1
+noop
+noop
+addx -38
+addx 39
+addx -32
+noop
+noop
+noop
+addx 5
+addx 2
+addx -1
+addx 4
+noop
+addx 5
+addx -2
+addx 5
+addx 2
+addx -26
+addx 31
+addx -2
+addx 4
+addx 3
+addx -18
+addx 19
+addx -38
+addx 7
+noop
+noop
+addx 34
+addx -39
+addx 8
+addx 5
+addx 2
+addx 10
+addx -5
+addx -2
+addx 5
+addx 2
+addx 11
+addx -6
+noop
+addx 3
+noop
+addx 2
+addx 3
+addx -2
+addx -38
+noop
+noop
+noop
+addx 5
+addx 11
+noop
+addx -3
+noop
+noop
+noop
+addx 2
+noop
+addx -11
+addx 16
+noop
+addx 3
+addx 2
+addx 8
+noop
+noop
+noop
+noop
+noop
+addx 4
+addx 3
+noop
+addx -20
+noop
diff --git a/2022/10/puzzle-1.awk b/2022/10/puzzle-1.awk
new file mode 100755
index 0000000..16c684b
--- /dev/null
+++ b/2022/10/puzzle-1.awk
@@ -0,0 +1,8 @@
+#!/usr/bin/awk -f
+
+BEGIN { x = 1 }
+
+{ if ((++c - 20) % 40 == 0) s += c * x }
+/addx/ { if ((++c - 20) % 40 == 0) s += c * x; x += $2 }
+
+END { print s }
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 }