#prepare the input which is a string containing new lines def parse(input) data = [] input.each_line do |line| data << line.split(":").last.gsub(" ","").to_i puts data end data end # result should a single string or integer def calculate(data) win_count = 0 time,distance = data win_count = 0 (1..time).each do |duration| speed = duration time_left = time - duration travel_distance = speed * time_left win_count += 1 if travel_distance > distance end win_count end