#prepare the input which is a string containing new lines def parse(input) data = [] input.each_line do |line| data << line.gsub(/[a-zA-Z]/,"").chomp end data end # result should a single string or integer def calculate(data) result = 0 data.each do |d| d = d.chars.to_a num = "#{d.first}"+"#{d.last}" result += num.to_i end result end