aoc2022/d10/part1.awk

11 lines
152 B
Awk
Raw Normal View History

2022-12-10 18:56:16 +00:00
BEGIN { x=1 }
function inc() {
c+=1
S += index("20,60,100,140,180,220,", c ",")>0 ? x*c : 0
}
{ inc() }
$1 == "addx" {
inc()
x+=$2
}
END { print S }