solved problem 10 in Ruby