12 lines
195 B
Ruby
12 lines
195 B
Ruby
|
#!/usr/bin/env ruby
|
||
|
|
||
|
problem = 3
|
||
|
input = File.readlines("#{problem}.input").join
|
||
|
|
||
|
result = input
|
||
|
.scan(/mul\((\d{1,3}),(\d{1,3})\)/)
|
||
|
.map { _1.map(&:to_i).inject(1, :*) }
|
||
|
.sum
|
||
|
|
||
|
puts result
|