day 10, part 2, no need to buffer, spare 6 loc

This commit is contained in:
setop 2023-01-01 19:45:07 +01:00
parent 4f3a52c210
commit a83c910cc7
1 changed files with 7 additions and 13 deletions

View File

@ -1,20 +1,14 @@
BEGIN { x=1 }
function inc() {
i = (c%40)
A[c+1] = (i==x-1||i==x||i==x+1) ? "█" : "░"
c+=1
i = (c%40)
r = r ((i==x||i==x+1||i==x+2) ? "█" : " ")
if (i == 39) {
print r
r = ""
}
c++
}
{ 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
}
}