summaryrefslogtreecommitdiff
path: root/2024/03a/run.rb
diff options
context:
space:
mode:
authormms <git@sapka.me>2024-12-03 08:52:26 +0100
committermms <git@sapka.me>2024-12-03 08:52:26 +0100
commit1ea90d8757b788e8711b961b818f41671049d7ae (patch)
treedaae16a2f5d712329ee7213b214832e3b490faae /2024/03a/run.rb
parent558e9a668287b318a400725d1b6ad38e6753d54c (diff)
feat: 2024@3a
Diffstat (limited to '2024/03a/run.rb')
-rwxr-xr-x2024/03a/run.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/2024/03a/run.rb b/2024/03a/run.rb
new file mode 100755
index 0000000..1effb9b
--- /dev/null
+++ b/2024/03a/run.rb
@@ -0,0 +1,12 @@
+#!/usr/bin/env ruby
+
+data = File.read("data.txt")
+
+valid = data.scan(/mul\(\d*,\d*\)/)
+sum = 0;
+
+ops = valid.map do |operation|
+ operation.gsub(/[^\d*,]/, "").to_s.split(",").map(&:to_i).reduce(&:*)
+end
+
+p ops.sum