aboutsummaryrefslogtreecommitdiff
path: root/2022/10/puzzle-1.awk
blob: 16c684b1c57c7ffe04ddc2c9e37a7f4b2862c7e0 (plain) (blame)
1
2
3
4
5
6
7
8
#!/usr/bin/awk -f

BEGIN { x = 1 }

{ if ((++c - 20) % 40 == 0) s += c * x }
/addx/ { if ((++c - 20) % 40 == 0) s += c * x; x += $2 }

END { print s }