Menu
CoddyTech

Recap: Sensor Run

Lesson 14 of 48 in Coddy's Ruby for Python Developers course.

challenge icon

Challenge

Easy

Input is integers. Skip zeros; stop at first negative; return count and sum of earlier positive values separated by a space.

Return text from solve(input) without printing. The locked driver prints the returned text with one final newline and checks required public APIs independently.

Your code goes in exercise.rb. main.rb holds the supplied input/output code and cannot be edited.

Try it yourself

require_relative 'exercise'
def check(value)
  raise 'Public API check failed' unless value
end

puts solve(STDIN.read)

All lessons in Ruby for Python Developers

Practice on your own: Online Ruby compiler