BEGIN { x=1 } function inc() { i = (c%40) A[c+1] = (i==x-1||i==x||i==x+1) ? "█" : "░" c+=1 } { 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 } }