From 54c626efc3c2d1f0e8fb1c2db43b71ba7c4caedc Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Mon, 2 Dec 2024 21:20:55 -0800 Subject: [PATCH] [2024][ruby][3.x] --- 2024/ruby/day_03.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 2024/ruby/day_03.rb diff --git a/2024/ruby/day_03.rb b/2024/ruby/day_03.rb new file mode 100644 index 0000000..d307b67 --- /dev/null +++ b/2024/ruby/day_03.rb @@ -0,0 +1,9 @@ +input = DATA.read + .gsub(/don't\(\)(?~do\(\))do\(\)/, "") # part two + .scan(/mul\((\d+),(\d+)\)/) + .map { _1.map(&:to_i) } + +pp input.sum { _1 * _2 } + +__END__ +xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))