diff options
author | Thomas Voss <mail@thomasvoss.com> | 2022-12-11 23:27:34 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2022-12-11 23:27:34 +0100 |
commit | fbee8c65aa88b94e97b2cb6b29f615859bf34660 (patch) | |
tree | fe9dba897bc91cb12ceb20f5ba56a8a4f0c9dd8f /2022/10/puzzle-1.awk | |
parent | 603fb558d957201754cc3e64004f83e2f9ff4745 (diff) |
Add 2022 day 10 solutions
Diffstat (limited to '2022/10/puzzle-1.awk')
-rwxr-xr-x | 2022/10/puzzle-1.awk | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/2022/10/puzzle-1.awk b/2022/10/puzzle-1.awk new file mode 100755 index 0000000..16c684b --- /dev/null +++ b/2022/10/puzzle-1.awk @@ -0,0 +1,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 } |