summary refs log tree commit diff homepage
path: root/2022
diff options
context:
space:
mode:
Diffstat (limited to '2022')
-rw-r--r--2022/day05.awk8
1 files changed, 8 insertions, 0 deletions
diff --git a/2022/day05.awk b/2022/day05.awk
index 599b1a4..34f8cc4 100644
--- a/2022/day05.awk
+++ b/2022/day05.awk
@@ -7,6 +7,7 @@
 		x = substr($i, 2, 1);
 		if (x == ".") continue;
 		a[i] = a[i] x;
+		b[i] = b[i] x;
 	}
 }
 /^move/ {
@@ -18,10 +19,17 @@
 		a[from] = substr(a[from], 2);
 		a[to] = x a[to];
 	}
+	x = substr(b[from], 1, count);
+	b[from] = substr(b[from], count+1);
+	b[to] = x b[to];
 }
 END {
 	for (i = 1; a[i]; i++) {
 		printf substr(a[i], 1, 1);
 	}
 	printf "\n";
+	for (i = 1; b[i]; i++) {
+		printf substr(b[i], 1, 1);
+	}
+	printf "\n";
 }