about summary refs log tree commit diff
path: root/aoc/2022/10/part-one.awk
blob: 756464e3a6b41bf93aaf7808bf904885567fa9de (plain) (blame)
1
2
3
4
5
6
7
8
#!/usr/bin/env -S awk -f
BEGIN { cycle = x = 1 }
{ cycle++ }
cycle % 40 == 20 { strength += cycle * x }
{ x += $2 }
/^addx/ { cycle++ }
/^addx/ && cycle % 40 == 20 { strength += cycle * x }
END { print strength }