diff --git a/d10/part1.awk b/d10/part1.awk new file mode 100644 index 0000000..302fa7d --- /dev/null +++ b/d10/part1.awk @@ -0,0 +1,13 @@ +BEGIN { x=1 } +function inc() { + c+=1 + if (index("20,60,100,140,180,220,", c ",")>0) { + S += x*c + } +} +{ inc() } +$1 == "addx" { + inc() + x+=$2 +} +END { print S } \ No newline at end of file