From 42a525352a71f31bd25a43335f80a3166fbe85af Mon Sep 17 00:00:00 2001 From: setop Date: Mon, 2 Jan 2023 12:35:09 +0100 Subject: [PATCH] day 10, part 2, no need to buffer, spare 10 loc --- d10/part2.awk | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/d10/part2.awk b/d10/part2.awk index a58678f..72d1ef8 100644 --- a/d10/part2.awk +++ b/d10/part2.awk @@ -1,20 +1,10 @@ -BEGIN { x=1 } function inc() { - i = (c%40) - A[c+1] = (i==x-1||i==x||i==x+1) ? "█" : "░" - c+=1 + i = (c++%40) + printf "%s", (i==x||i==x+1||i==x+2) ? "█" : " " + printf "%s", (i==39) ? "\n" : "" } { inc() } $1 == "addx" { inc() - x+=$2 -} -END { - for (i=0;i<=5;i++) { - r = "" - for (j=1;j<=40;j++) { - r = r A[i*40+j] - } - print r - } + x += $2 } \ No newline at end of file