summaryrefslogtreecommitdiff
path: root/2024/03a/run.rb
blob: 1effb9b8ab7a836a98765098d9b143ca34090932 (plain)
1
2
3
4
5
6
7
8
9
10
11
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