aoc2022/d10/part2.awk

10 lines
160 B
Awk
Raw Permalink Normal View History

function inc() {
i = (c++%40)
printf "%s", (i==x||i==x+1||i==x+2) ? "█" : " "
printf "%s", (i==39) ? "\n" : ""
}
{ inc() }
$1 == "addx" {
inc()
x += $2
}