12 lines
230 B
Ruby
Executable file
12 lines
230 B
Ruby
Executable file
#!/usr/bin/env ruby
|
|
|
|
input = File.readlines("1.input").map(&:split)
|
|
|
|
first = input.map(&:first).compact
|
|
last = input.map(&:last).compact
|
|
|
|
result = first.map do |v|
|
|
v.to_i * last.select { _1.match?(v) }.size
|
|
end.sum
|
|
|
|
puts result
|