From 192d9b1ad6e0fc1c96619ba6f4ad1b740c5ef8b2 Mon Sep 17 00:00:00 2001 From: setop Date: Sun, 1 Jan 2023 20:14:00 +0100 Subject: [PATCH] day 10, part 2, no need to buffer, spare 10 loc --- d10/part2.awk | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/d10/part2.awk b/d10/part2.awk index a58678f..810a109 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) # inc c after + printf "%s", (i==x||i==x+1||i==x+2) ? "█" : " " + if (i == 39) { print "" } } { 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 - } -} \ No newline at end of file