From 38a377ac846389f0d46e2558365fac567f0bfb3e Mon Sep 17 00:00:00 2001 From: setop Date: Sat, 10 Dec 2022 19:56:16 +0100 Subject: [PATCH] day 10, awk solution for part 1 --- d10/part1.awk | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 d10/part1.awk diff --git a/d10/part1.awk b/d10/part1.awk new file mode 100644 index 0000000..d5f0ff1 --- /dev/null +++ b/d10/part1.awk @@ -0,0 +1,11 @@ +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 } \ No newline at end of file