From 498deb991b3774ecb79e34c574f8db6d4883164f Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Mon, 5 Dec 2022 10:09:29 -0500 Subject: Solve day 5 part 2 --- 2022/day05.awk | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to '2022') 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"; } -- cgit 1.4.1