aoc2022/d10/part2.awk

11 lines
167 B
Awk
Raw Normal View History

function inc() {
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
}