aboutsummaryrefslogtreecommitdiff
path: root/2024/03/puzzle-1.sh
diff options
context:
space:
mode:
Diffstat (limited to '2024/03/puzzle-1.sh')
-rwxr-xr-x2024/03/puzzle-1.sh7
1 files changed, 7 insertions, 0 deletions
diff --git a/2024/03/puzzle-1.sh b/2024/03/puzzle-1.sh
new file mode 100755
index 0000000..c0f2f38
--- /dev/null
+++ b/2024/03/puzzle-1.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+grep -Eo 'mul\([0-9]+,[0-9]+\)' input \
+| awk 'BEGIN { FPAT = "[0-9]+" }
+ { x += $1 * $2 }
+ END { print x }
+' \ No newline at end of file